Define the matrix with the command sym

>> sym_matrix = sym('[a,b,c;Jack,HelpMe,NOWAY]')
错误使用 sym>convertChar
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'.
出错 sym>tomupad (第 1481 行)
S = convertChar(x);
出错 sym (第 249 行)
S.s = tomupad(x);
相关文档
是不是想输入:
>> sym_matrix = str2sym('[a,b,c;Jack,HelpMe,NOWAY]')
sym_matrix =
[ a, b, c]
[Jack, HelpMe, NOWAY]

回答 (2 件)

Walter Roberson
Walter Roberson 2024 年 1 月 3 日

0 投票

Up to roughly R2018a or so, it was valid to sym() a character string that represented an expression . Now it is only valid to sym() something numeric or to sym() a character string that represents a scalar numeric or to sym() a character string that represents a scalar variable name.
The replacement syntax is the str2sym() that you already found.

1 件のコメント

童战
童战 2024 年 1 月 3 日
Appreciate the assistance with my MATLAB question! Thank you!

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

madhan ravi
madhan ravi 2024 年 1 月 3 日

0 投票

As it suggests 'Character vectors and strings in the first argument can only specify a variable or number.'
It can be a variable with subscripts as mentioned in the
doc sym
Anyways seems like you have used the correct syntax using str2sym() at the end.

1 件のコメント

童战
童战 2024 年 1 月 3 日
Okey! Appreciate the assistance with my MATLAB question! Thank you!

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

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

製品

リリース

R2023a

質問済み:

2024 年 1 月 3 日

コメント済み:

2024 年 1 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by