Substitute equation into another one

4 次查看(过去 30 天)
Hi,
I'm wondering whether there is a neat way to substitute an equation into another one.
Example:
1st equation: x*dx*dy+dy*dz*x+z
2nd equation: dx+dz=u
Expected solution: x*dy*u+z
How do I do that? Right now I wrote a script, which can do it (but its 70 lines long and quite slow). Is there an easy solution?
Thank you very much!
Product: Matlab 2012a

采纳的回答

Argon
Argon 2012-10-31
Like that?
f = sym('x*dx*dy+dy*dz*x+z');
g = sym('dx+dz=u');
simplify(subs(f, 'dx', solve(g, 'dx')))
Of course, it gets harder if your equation is non-linear...
  1 个评论
Moritz
Moritz 2012-10-31
So simple and so brilliant. Looks like I couldn't see the forest for the trees... Thanks a lot!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by