Hello,
I am attempting to fit data that involves solving a fifth order polynomial for the real positive root. I need to calculate the real positive root over a set of values, so I was trying to use syms with a loop in order to get the root with each iteration of the symbolic polynomial. It should have five roots, though I just need one. I'm not very good at using syms so I am likely confusing some syntax. It tells me the error "Conversion to logical from sym is not possible". I imagine this is because MatLab thinks I am still using a symbolic variable when doing the logic check, which it doesn't understand. Though I thought my program has converted back to numerical at that point. Does anyone know a good way to do this?
Thank you.
syms X Y
for i = 1:length(injections)
Y = C1(i,1).*X + C2.*X + C3(i,1).*X +
C4(i,1).*X^2 + C5.*X^2 + C6(i,1).*X^2 + C7(i,1).*X^3 +
C8.*X^3 + C9(i,1).*X^3 + C10(i,1).*X^4 + C11.*X^4 +
C12(i,1).*X^4 + C13.*X^5;
realposans(:,i) = solve(Y == 0,'Real',true);
for j = 1:size(realposans,1)
if realposans(j,i) > 0
LF(i,1) = realposans(j,i);
end
end
end
Best Answer