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

 採用された回答

madhan ravi
madhan ravi 2019 年 4 月 22 日
編集済み: madhan ravi 2019 年 4 月 22 日

0 投票

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 件のコメント

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

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2019 年 4 月 22 日

0 投票

syms x
e3 = sin(x)^2+cos(x)==0

Community Treasure Hunt

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

Start Hunting!

Translated by