Hi @萌 孟
I see that you are trying to solve a cubic equation and find real solutions using “solve”.
The error suggests that some coefficients of “sita1” in the equation “h” are not real. Make sure to check that all your inputs and coefficients are real if that's your requirement.
If the coefficients are meant to be complex, you can address the error by allowing “solve” to solve for all solutions and then select only the real solutions.
To do this, the line
sita1 = solve(h == 0, sita1, 'Real',1);
should be replaced with
sita1 = solve(h == 0, sita1);
sita1 = double(sita1);
sita1 = sita1(imag(sita1) == 0);
For more information on “solve” and “imag” you can refer to the following links:
Or you can type the following lines in a MATLAB command window for version specific documentation:
doc solve
doc imag
