how to properly use 'solve' function properly?

1 次查看(过去 30 天)
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.

回答(1 个)

Walter Roberson
Walter Roberson 2013-3-30
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.
  2 个评论
Dany
Dany 2013-3-31
thank you i'll try that. if i may ask, how did you get the general solution?
i know that in some circumstances it could give a NaN but i was talking on the same input number in both cases, only in matlab i get NaN.
Dany
Dany 2013-3-31
the general solution seems to work. but when i use the 'solve' function i keep getting an expretion with 'wrightOmega' in it and even when i use 'subs' i get an error saying double values cant be used in the 'wrightOmega' function.

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by