Nesting the value of variable in fsolve?

7 views (last 30 days)
I am trying to nest a variable in function f(E). And thes variable, say V, is also a function of E.
For example,
V=exp(E(1))+E(2);
f=@(E) [E(1)+34*E(2); E(1)+(2+V*8)*E(2)]
The above code is hypothetical for better presentation for you.
If we run this kind of problem(I will fsolve it), it will show error such as E(1) and E(2) is not defined.
So if I code
syms E
then it will not deliver answer from function f.
What can you suggest when solving this problem?
ps. Again, above example is just an example. Thanks!
I love Matlab!!!

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 31 Mar 2012
use
V = @(E)exp(E(1)) + E (2);
F = @(E)[E (1) +34 * E (2), E (1) + (2 + V(E) * 8) * E (2)]
OR
F = @(E)[E(1) +34 * E(2), E(1) + (2 + (exp(E(1)) + E(2))*8)* E(2)]
  1 Comment
Joon Jeon
Joon Jeon on 31 Mar 2012
Thanks, it worked!
Could you answer my another question if you don't mind?
Question Below:
http://www.mathworks.se/matlabcentral/answers/34089-can-i-use-this-result-after-fsolve

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!