"Conversion to logical from sym is not possible" arising in bisection method

1 回表示 (過去 30 日間)
Pritha
Pritha 2021 年 5 月 17 日
回答済み: Walter Roberson 2021 年 5 月 17 日
The following is my code. i want to calculate gss here. problem arising in " if f(gss1)*f(gss2) < 0 ". In command window " Conversion to logical from sym is not possible. " this type of comment is showing. Want some help to do this. thanks in advance.
syms gss
m = 4.7542;
gsms = 11.299 ;
gomo = 5.696 ;
gpmp = 4.656 ;
m1 = (m - gss);
p = 0 ;
k = (3 * p * pi^2 / 2)^(1/3) ;
k1 = sqrt(k^2 + m1^2);
goo = gomo * p ;
moo = goo * p/2 ;
f(gss) = (gss - (gsms * m1 * (k1 - m1^2/2 *log((k1+k)/m1))/pi^2 )) ;
pretty(f);
gss1 = input('gss1=');
gss2 = input('gss2=');
if f(gss1)*f(gss2) < 0
gss = (gss1+gss2)/2 ;
n = 0;
while abs (f(gss))> 0.00001
n = n + 1;
gss = (gss1 + gss2)/2;
if f(gss1)*f(gss)< 0
gss2 = gss;
else
gss1 = gss;
end
end
fprint('no root')
end

採用された回答

Walter Roberson
Walter Roberson 2021 年 5 月 17 日
fgss = (gss - (gsms * m1 * (k1 - m1^2/2 *log((k1+k)/m1))/pi^2 )) ;
f = matlabFunction(fgss)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFormula Manipulation and Simplification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by