Error using sym>convertChar (line 1448)

조회 수: 23 (최근 30일)
Dursman Mchabe
Dursman Mchabe 2018년 8월 13일
댓글: Dursman Mchabe 2018년 8월 13일
Hi everyone,
I get the error message:
"Error using sym>convertChar (line 1448) 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 1214) S = convertChar(x);
Error in sym (line 211) S.s = tomupad(x);
Error in SolveExample>TurnEqIntoDEq (line 43) depVarsLong(k) = sym([char(depVars(k)) '(' char(indepVar) ')']);
Error in SolveExample (line 21) [dEq3, initEq3] = TurnEqIntoDEq(Eq1, [a b c], t, 0);"
when I run the attached code. What can I do?

채택된 답변

Tiasa Ghosh
Tiasa Ghosh 2018년 8월 13일
편집: Tiasa Ghosh 2018년 8월 13일
You have used the function subs() for substitution in your function TurnEqIntoDEq . The input to subs (L47 in your code file) is a string. But the function 'subs' expects a symbolic variable or expression. So in the parent file, convert the Eq1 to symbolic string with str2sym and then pass it to TurnEqIntoDEq function. Also, use str2sym for depVarsLong(k) and depVarsShort(k) in TurnEqIntoDEq. I have done the same to the file attached.
  댓글 수: 6
Dursman Mchabe
Dursman Mchabe 2018년 8월 13일
Thanks a lot. The code your amendments worked. I truly appreciate.
Dursman Mchabe
Dursman Mchabe 2018년 8월 13일
Thanks a lot. The code you uploaded works. I truly appreciate.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by