Matlab gives NaN when i use the name of a variable

1 回表示 (過去 30 日間)
Yagmur Gencoglu
Yagmur Gencoglu 2019 年 6 月 3 日
コメント済み: Walter Roberson 2019 年 6 月 4 日
Greetings,
I have been working on an optimization code with a lot of iterations.
I wrote an equation with syms in it to use. But when i try to use eval for one of the equations, it gives me NaN.
For example at the following part of the code;
"Ccurr = eval(subs(F,alph,alpha));
Cnew = eval(subs(F,alph,alphanew));
erralpha = abs((Cnew-Ccurr)*100/Ccurr);
alpha = alphanew;"
Here, Cnew is seen as NaN. But when i write "Cnew = eval(subs(F,alph,58473000))" directly with the value of alphanew; it gives a numerical result.
How can i fix this?
Thanks in advance.
  6 件のコメント
Yagmur Gencoglu
Yagmur Gencoglu 2019 年 6 月 3 日
SRH is actually calculated before the while loop starts. Again, when i put anything else in place of "alphanew" i get a result.
Thanks for your answer.
Walter Roberson
Walter Roberson 2019 年 6 月 4 日
We cannot test without knowing the values of all variables you use in the code.

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by