how to properly use 'solve' function properly?
2 views (last 30 days)
Show older comments
hi, my question might sound weired. i have this equation:
x/L - 1 + (h+eta)/ho + A*log(((h+eta)/ho - A)/(1-A)) = 0
all parameters are known numbers except 'eta'. when i solve this equation in my TI calculator using 'nSolve' it works fine and i get a solution, but when im trying to solve it with matlab using 'eval(solve(f,eta))' im getting NaN as an answer.
what am i doing wrong? how to resolve this problem?
thank you.
0 Comments
Answers (1)
Walter Roberson
on 30 Mar 2013
Do not eval() a symbolic formula. If the formula contains symbolic variables then use subs() on it; if the formula does not contain symbolic variables then use double() to represent the number a double precision.
The general solution for the above is
-ho*(-1+A)*exp((-lambertw(-(-1+A)*exp(((1-A)*L-x)/(A*L))/A)*A*L+(1-A)*L-x)/(A*L))+A*ho-h
there are a number of circumstances under which the above could generate a NaN, such as if A or L is 0.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!