This enhancement has been incorporated in Release 2013a (R2013a). For previous product releases, read below for any possible workarounds:
In Symbolic Math Toolbox 5.4 (R2010a), SUBS can only be used to substitute a variable in an expression with another variable or expression. SUBS may not be used to substitute a sub-expression in an expression.
As a workaround, you can use SUBSEX, available in the MuPAD language, to substitute a sub-expression in an expression. You may call this function with the help of FEVAL as follows:
q = feval(symengine,'subsex',u,[char(w0) '=w0'])
q =
a*cos(t*w0 + 3) + b*sin(5*t*w0 + 3)
You can also create an anonymous function to mimic SUBS:
subsx = @(u,w0,w0str) feval(symengine,'subsex',u,[char(w0) '=' w0str]);
p3 = subsx(u, w0, 'w0')
You may read more about SUBSEX in the MuPAD help documentation at:
<http://www.mathworks.com/help/releases/R2013a/symbolic/mupad_ref/subsex.html>
Best Answer