problem using 'Solve' (return only 1 solution)
20 views (last 30 days)
Marco Picillo on 22 May 2021
I have a problem using solve for a symbolic expression (i'm using Matlab 2019a). I have a 3rd degree polynomial symbolic expression, and i want to find the roots.
and matlab returns:
But i expected 3 real solutions, in fact i tried using 'roots' and the solutions are:
p=[0.638 0.360 -0.860988 0.0401];
(i approximated the coefficients). Seems that Matlab returns me only the last solution. What's the problem?
Andreas Apostolatos on 22 May 2021
It is not clear how you define expression 'equazione_gamma', but by reverse engineering your call to function 'roots', I believe that you define 'equazione_gamma' as '0.638*CL^3 + 0.360*CL^2 - 0.860988*CL + 0.0401' where 'CL' is a symbolic variable.
This way, the following script provides all three expected solutions in both MATLAB R2019a (both in general release and in Update 9) and MATLAB R2021a, namely,
equazione_gamma = 0.638*CL^3 + 0.360*CL^2 - 0.860988*CL + 0.0401;
[soluzione] = vpa(solve(equazione_gamma,CL,'Real',true))
I hope this information helps.