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

2 views (last 30 days)
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

Accepted Answer

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

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!