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

 Accepted Answer

madhan ravi
madhan ravi on 22 Apr 2019
Edited: madhan ravi on 22 Apr 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 Comments

Why can not I input e3=sym('sin(x)^2+cos(x)=0')
See the reason in the edited answer.
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);
Post this information in the question you recently asked. This is completely irrelevant to this question.
>> clear
>> sym('a')
ans =
a
I can use sym('a'). Why can not I use sym('a+b')?
Why not use str2sym('a') instead of sym('a’)?
It only works for only a number or a variable. Read the documentations. Take MATLAB on-ramp course to learn the basics of MATLAB.

Sign in to comment.

More Answers (1)

Community Treasure Hunt

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

Start Hunting!