Algebraic solver with multiple outputs?

4 views (last 30 days)
Rudy
Rudy on 8 Mar 2014
Answered: Matt J on 9 Mar 2014
Hi there,
I am searching for a function which can solve an equation and give multiple outputs. I have already tried solve and fzero but these seem not to do what I want.
The equation I want to solve is the following:
for k = 1:length(dH)
T = @(u)((dct*exp(-(u-dH(k)).^2/(wH))) - (u./sqrt(1+u.^2)-ctyi));
fzero(T,[0 4])
end
In which dct, wH and ctyi are all constants. dH changes each iteration. Thus each iteration there is a equation for which the zeros need to be found. I want to solve for u in a range of [0 4]. I know that there are max 3 solutions.
Any suggestions? Thanks for your help.
Kind regards, Rudy
  2 Comments
Rudy
Rudy on 8 Mar 2014
Edited: Matt J on 9 Mar 2014
I have tried the following:
dct = 1;
ctyi = -0.5;
dH = 0.5;
syms u
x = -1:0.01:3;
for k = 1:length(dH)
for i = 1:length(x);
T = @(u)((dct*exp(-(u-k).^2/(wH))) - (u./sqrt(1+u.^2)-ctyi));
J(i) = fzero(T,i);
end
end
Just for one value of dH now. It gives only 1 solution, which I find weird since if I make the following plot:
u = -1:0.01:3;
plot((dct*exp(-(u-dH).^2/(wH))) - (u./sqrt(1+u.^2)-ctyi))
I see that there are three zeros.
Matt J
Matt J on 9 Mar 2014
"syms u" is not accomplishing anything in the above. You are not using it to build a symbolic version of T and you are not applying the SOLVE command.

Sign in to comment.

Answers (1)

Matt J
Matt J on 9 Mar 2014
If SOLVE cannot find all 3 roots symbolically (though note my comment above, it's not clear that you ever applied SOLVE correctly), then it's doubtful you can obtain all 3 unless you apply fzero 3 times, each time with a close initial numerical estimate of the root. You can probably obtain good initial estimates by doing,
u = 0:0.01:4;
u_estimates=u(abs(T(u))<somethingsmall);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!