MATLAB: Simplifying a series of non-linear equations as a function of specific variables

non-linearseries of equationssymbolic

If I have a series of non-linear equations: a=f(x,y,z,w), x=g(z,w), y=h(z,w), and I want to get a result a=F(x,y) (i.e. for matlab to substitute x,y in the original function with the corresponding functions that are dependent on z,w so that I can get a result for a that is only dependent on z,w). Is there a way for me to have Matlab do this?
ex. a=x+y^2+x*z+y*w*2, x=z^2, y=w+z would result in: a=z^2+(w+z)^2+z^3+z^2(w+z)

Best Answer

syms a x y w z
a=z+y^2+x*z+y*w*2;
a=subs(z+y^2+x*z+y*w*2,[x,y],[z^2,w+z])
Related Question