Why does the SUBS command not substitute correctly for a symbolic term of variables?

5 views (last 30 days)
Why does the SUBS command not substitute correctly for a symbolic term of variables?
SUBS does not replace symbolic terms that contain only multiplication operators.
For example:
» syms r q z s;
f2=(r*q+1)*s;
C = maple('coeff',f2,s,1);
subs(f2,C,'C')
ans =
C*s
however,
» f1=(r*q)*s;
C = maple('coeff',f1,s,1);
subs(f1,C,'C')
ans =
r*q*s

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Jun 2018
This behavior has been submitted to our development staff as a bug.
As a workaround, you can change the symbolic variables to a string and then perform the SUBS command. You can do this with the CHAR command in the following manner:
The CHAR command in MATLAB creates character arrays. For more information information on how to use the syntax, please refer to the MATLAB User's Guide function reference at the URL below :
f1=(r*q)*s;
C = maple('coeff',f1,s,1);
subs(f1,char(C),'C')
ans =
(C)*s

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!