Why does the SUBS command in Symbolic Math Toolbox 5.1 (R2008b) return an error when used to substitute variable 'D'?
5 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2010 年 4 月 19 日
コメント済み: Walter Roberson
2024 年 4 月 18 日
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
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
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
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)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Mathematical Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!