Substitute implicit dependent expressions into another one

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?

2 comentarios

Could you tell what’s your desired result?
Lyz
Lyz el 7 de Jun. de 2020
Actually, I would like to check a result I get calculated by hand.
Xm1,Xm12,Xm2,Xt are my steady state values for a complex eq system and by hand I got the implicit results above.
I would like to substitute them back into the equations in my system and see that for different values I really get zeros for these equation.
Thank you for the quick response!

Iniciar sesión para comentar.

 Respuesta aceptada

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.
.

4 comentarios

Lyz
Lyz el 7 de Jun. de 2020
Thank you for your answer!
I tried that you wrote but probably I misunderstood it.
In the end I suppose to get a number for this expression:
pt*Xt*(1-Xt/Kt)*(1+rm2*Xm2+rm12*Xm12)-dt1*Xt*Xm1-dt2*Xt*Xm12
but whatever I try, my Xm1,Xm12,Xt always remain a variable instead. :(
Star Strider
Star Strider el 7 de Jun. de 2020
Editada: Star Strider el 7 de Jun. de 2020
My pleasure!
It is straightforward to keep ‘Xm1’, ‘Xm12’, and ‘Xt’ as variables. Simply do not substitute them, and to make this easier, specify them as the argument list to your function.
The revised code:
syms pt Kt Ktstar rm12 dt1 dt2 pm1 pm12 Km am1 am21 dm1 dm12 am12 dm pm Xm12 Xt Xm1
% Xm1=Km*(1-dm/pm)-Xm12;
% Xm12=(am1*Xm1/am21)*(Xt/(Xt+Ktstar));
% Xm2=0;
Eqn = subs(Kt*(1-(dt1*Xm1-dt2*Xm12))/(pt*(1+rm12*Xm12)) - Xt, {Xm1,Xm12},{Km*(1-dm/pm)-Xm12, (am1*Xm1/am21)*(Xt/(Xt+Ktstar))});
fcn(Xm1, Xm12, Xt) = simplify(Eqn, 'Steps',500)
The original function is:
fcn(Xm1, Xm12, Xt) =
(Kt*(dt1*(Xm12 + Km*(dm/pm - 1)) + (Xm1*Xt*am1*dt2)/(am21*(Ktstar + Xt)) + 1))/(pt*((Xm1*Xt*am1*rm12)/(am21*(Ktstar + Xt)) + 1)) - Xt
The subs call would go like this:
fcn(Xm1, Xm12, Xt) = subs(fcn, {pt Kt Ktstar rm12 dt1 dt2 pm1 pm12 Km am1 am21 dm1 dm12 am12 dm pm},{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16})
producing (with these scalars):
fcn(Xm1, Xm12, Xt) =
(2*(5*Xm12 + (60*Xm1*Xt)/(11*(Xt + 3)) - 29/16))/((40*Xm1*Xt)/(11*(Xt + 3)) + 1) - Xt
Use the appropriate parameter values. (I used this string of numbers simply to test the code.)
.
Lyz
Lyz el 7 de Jun. de 2020
Thank you very much for your help! I could solve now that I wanted :D
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Function Creation en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Lyz
el 7 de Jun. de 2020

Comentada:

el 7 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by