Matlab Simplify function in terms of defined function

16 visualizaciones (últimos 30 días)
Mike C
Mike C el 8 de Nov. de 2016
Respondida: Walter Roberson el 8 de Nov. de 2016
I have a long expression I am trying to simplify into known expressions, using symbolic editor.
For example, if I know/define,
M=X/Z
N=Z/Y,
then I would like if I write:
simplify(X/Y) to return M*N.
Is this possible? My expression that I would be simplifying is much longer, but I would like it to return defined "known" functions.
Thanks

Respuestas (1)

Walter Roberson
Walter Roberson el 8 de Nov. de 2016
The closest MATLAB gets to that is https://www.mathworks.com/help/symbolic/subexpr.html which is common sub-expression optimization, with no real controls.
The trick I tend to use is
subs(X/Y, {X, Y}, {M*Z, Z/N})
that is, solve the expression M is replacing in terms of one of the other variables and then subs() replacing the other variable with the result. It is a bit clumsy, because it replaces all occurrences of the variable.
children() can help sometimes.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by