Why is it wrong: e3=sym('si​n(x)^2+cos​(x)=0')

 Respuesta aceptada

madhan ravi
madhan ravi el 22 de Abr. de 2019
Editada: madhan ravi el 22 de Abr. de 2019
sym('') was replaced by str2sym('') in latest versions and you seem to be using 2018b version
e3=str2sym('sin(x)^2+cos(x)=0')
% ^^^^^^^

10 comentarios

zhenyu zeng
zhenyu zeng el 22 de Abr. de 2019
Why can not I input e3=sym('sin(x)^2+cos(x)=0')
madhan ravi
madhan ravi el 22 de Abr. de 2019
See the reason in the edited answer.
zhenyu zeng
zhenyu zeng el 22 de Abr. de 2019
But I can input sym('a') not need to input str2sym('a'). Why?
Read the the error message clearly MATLAB states it clearly already:
Error using sym>convertChar (line 1459)
Character vectors and strings in the first argument can only
specify a variable or number. To evaluate character vectors and
strings representing symbolic expressions, use 'str2sym'.
Error in sym>tomupad (line 1225)
S = convertChar(x);
Error in sym (line 214)
S.s = tomupad(x);
madhan ravi
madhan ravi el 22 de Abr. de 2019
Post this information in the question you recently asked. This is completely irrelevant to this question.
zhenyu zeng
zhenyu zeng el 22 de Abr. de 2019
>> clear
>> sym('a')
ans =
a
zhenyu zeng
zhenyu zeng el 22 de Abr. de 2019
I can use sym('a'). Why can not I use sym('a+b')?
zhenyu zeng
zhenyu zeng el 22 de Abr. de 2019
Why not use str2sym('a') instead of sym('a’)?
madhan ravi
madhan ravi el 22 de Abr. de 2019
It only works for only a number or a variable. Read the documentations. Take MATLAB on-ramp course to learn the basics of MATLAB.

Iniciar sesión para comentar.

Más respuestas (1)

Etiquetas

Preguntada:

el 22 de Abr. de 2019

Comentada:

el 22 de Abr. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by