MATLAB: Substitute implicit dependent expressions into another one

implicitsubstitute

Hi Everyone!
This is my first question, so sorry for mistakes!
I would like to know that is there an opportunity to substitute implicit expressions which depend on eachother into another equation?
I have these equations:
Xm1=Km*(1-dm/pm)-Xm12;
Xm12=(am1*Xm1/am21)*(Xt/(Xt+Ktstar));
Xm2=0;
Xt=Kt*(1-(dt1*Xm1-dt2*Xm12))/(pt*(1+rm12*Xm12));
and I would like to substitute into
pt*Xt*(1-Xt/Kt)*(1+rm2*Xm2+rm12*Xm12)-dt1*Xt*Xm1-dt2*Xt*Xm12
I have values for the parameters: pt Kt Ktstar rm12 dt1 dt2 pm1 pm12 Km am1 am21 dm1 dm12 am12 dm pm
Can someone please help me?

Best Answer

I would start with this:
syms pt Kt Ktstar rm12 dt1 dt2 pm1 pm12 Km am1 am21 dm1 dm12 am12 dm pm Xm12 Xt
Xm1=Km*(1-dm/pm)-Xm12;
Xm12=(am1*Xm1/am21)*(Xt/(Xt+Ktstar));
% Xm2=0;
Xt=Kt*(1-(dt1*Xm1-dt2*Xm12))/(pt*(1+rm12*Xm12));
Xt = simplify(Xt, 'Steps',250)
producing:
Xt = (Kt*dt2)/(pt*rm12) - (Kt*(dt1*(Xm12 + Km*(dm/pm - 1)) + 1) - (Kt*dt2)/rm12)/(pt*((Xt*am1*rm12*(Xm12 + Km*(dm/pm - 1)))/(am21*(Ktstar + Xt)) - 1))
and then use the subs function to replace the parameters with their values.
.