Filter löschen
Filter löschen

how to properly use 'solve' function properly?

3 Ansichten (letzte 30 Tage)
Dany
Dany am 30 Mär. 2013
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.

Antworten (1)

Walter Roberson
Walter Roberson am 30 Mär. 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.
  2 Kommentare
Dany
Dany am 31 Mär. 2013
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 am 31 Mär. 2013
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.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by