MATLAB examples fail

I have no idea what is going on here, and Google does not offer any interesting help. I gave the following example from http://www.mathworks.com/help/toolbox/symbolic/solve.html#inputarg_eqn

>> syms x >> solve(x^2 + 4*x + 1 == 0) ??? Error using ==> char Conversion to char from logical is not possible. Error in ==> solve>getEqns at 169 vc = char(v); Error in ==> solve at 67 [eqns,vars] = getEqns(varargin{:}); 

What's going on here?

+6
source share
1 answer

The documentation you are reading does not apply to your version of MatLab. I can reproduce your error in 2008b, for example.

The old documentation says:

Note that these examples take equations of the form f(x) = 0 . If you need to solve equations of the form f(x) = q(x) , you should use quoted lines. In particular, the team

 s = solve('cos(2*x)+sin(x)=1') 

In the future, pay attention to the line at the top of each online MatLab documentation page, which indicates which version the documentation refers to.

+11
source

Source: https://habr.com/ru/post/911640/


All Articles