MATLAB: Matlab function “solve” couldn’t solve correctly

MATLABsolvesymbolicSymbolic Math Toolbox

syms x;
hold on;
As above, the equation "x.^2-sin(x+0.15)==x" should have 2 answers. I can tell from the plot of g and x.
While using the function " solve ", i could only get one answer as below.
Warning: Unable to solve symbolically. Returning a numeric approximation instead.
> In solve (line 304)
In test (line 3)
s =
Does it happen when "solve" Unable to solve symbolically, or is there something with my way of solving this problem. Thank you guys in advance.

Best Answer

  • fsolve(matlabFunction(g-x),[-1,2])
    % you can also use vpasolve() with random set to true in a loop to see the possibilities