フィルターのクリア

Why does the SUBS command in Symbolic Math Toolbox 5.1 (R2008b) return an error when used to substitute variable 'D'?

1 回表示 (過去 30 日間)
When I execute the following:
subs('A+D','D',3)
I receive the error,
ERROR: ??? Error using ==> mupadfeval at 28
Error: Illegal operand [subs];
during evaluation of 'mlsubs'
Error in ==> sym.subs at 219
G = sym(mupadfeval('mlsubs', charcmd(G), [x '=' charcmd(y)]));
Error in ==> sym.subs at 237
G = subs(F,Y,X,0);
Error in ==> subs at 60
r = subs(sym(f),varargin{:});
This only seems to occur when the second argument of the SUBS function is the string representation of variable 'D'. This command worked perfectly in the previous version of the Symbolic Math Toolbox (R2008a)

採用された回答

MathWorks Support Team
MathWorks Support Team 2024 年 4 月 18 日
編集済み: MathWorks Support Team 2024 年 4 月 18 日
The symbol 'D' is a reserved keyword in the MuPAD engine and is used to specify the differentiation operator. This and other such keywords cannot be used in string representations of expressions in the Symbolic Math Toolbox 5.1 (R2008b). More information about this can be found at the following link: 
You can work around this by using a symbolic variable instead. For example,
syms A D
subs(A + D, D, 3)
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 12 月 13 日
Related note:
Before R2020a,
syms pi
syms catalan
eulergamma
all produced symbolic references to symbolic constants -- for example
syms pi
used to indicate that the symbolic name pi should be associated with the symbolic constant π
As of R2020a, these names create plain symbolic variables that have no special meaning. Use
pi = sym(pi);
to have the variable named pi associated with the symbolic constant π -- sym() recognizes the floating point constant returned by the function pi() and converts it into a reference to the irrational constant π
Walter Roberson
Walter Roberson 2024 年 4 月 18 日
The error cannot occur these days, as it is no longer possible to use literal expressions in subs()
subs('A+D','D',3)
Error using sym>convertChar (line 1827)
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 1496)
S = convertChar(x);

Error in sym (line 268)
S.s = tomupad(x);

Error in subs (line 70)
r_unique_name = subs(sym(f_unique_name),varargin{:});

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematical Functions についてさらに検索

製品


リリース

R2008b

Community Treasure Hunt

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

Start Hunting!

Translated by