How can I substitute a sub-expression in a symbolic expression using Symbolic Math Toolbox
Ältere Kommentare anzeigen
I have an expressions like this:
syms c x a m
xs = (4*c*x*a^3 - 3*m*a)/(3*m)
psi = (2*c*x*a^2/3*m);
You can see that xs contains psi, but not in explicit form. I want to substitute psi into xs, to obtain this:
xs = (2*psi - 1)*a
I try these 2 options:
xs1 = feval(symengine,'subsex',xs,[char(psi) '=psi'])
xs2 = subs(xs, psi, 'psi')
It doesn't work. Any ideas how to solve this problem?
Symbolic Math Toolbox Version 6.1 (R2014b)
1 Kommentar
Walter Roberson
am 8 Sep. 2015
You want something similar to Maple's algsubs(), but Maple's routine will not find the match here.
One problem is that (2*psi-1)*a is not equal to the original xs. Look more carefully at your m. In the first subexpression of the original xs, after you divide through by the 3*m of the denominator, you are going to end up with a term divided by m. In your psi, you have a term multiplied by m, unless you say that
psi = (2*c*x*a^2/(3*m))
with that definition of psi, the two forms of xs do match.
Antworten (0)
Kategorien
Mehr zu Assumptions finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!