Extracting a symbolic variable (rearranging symbolic equation)

2 visualizaciones (últimos 30 días)
Tim
Tim el 11 de Abr. de 2011
Editada: Aider el 13 de Oct. de 2020
Hi,
I am trying to extract a variable (a gain in this case) from a symbolic expression.
The code for generating the symbolic expression is:
%Misc Intializations
syms K2 K1 s
%Plant characteristics
T=.1;
Wn=2.5;
z=.3;
%Controller
C=K2*expand((s+2)^2)/expand((s+10)*(s+100));
%Actuator
A=10/(s+10);
%Plant
P=K1*(T*s+1)/(s^2+2*Wn*z*s+Wn^2);
%Closed Loop TF
YcY=C*A*P/(1+C*A*P);
%Characteristic
KLs=expand(C*A*P);
Where the expression I want to work with is KLs, which in its current form is:
4*K1*K2*s^3 + 56*K1*K2*s^2 + 176*K1*K2*s + 160*K1*K2
----------------------------------------------------------
4*s^5 + 486*s^4 + 9145*s^3 + 55600*s^2 + 112500*s + 250000
I want to bring K1 and K2 outside the expression (make them into gains for the transfer function). In this case it is relatively simple to do so using coeffs however I need a method that will work when K1,K2...Kn can be in the numerator or the denominator.
Not sure if what I am asking is clear but thank you in advance for help!
  1 comentario
Mech Princess
Mech Princess el 20 de Jul. de 2012
Did you find a solution for this? I am trying to do something similar for another application. I am trying to have K1 on one side of equation and have all variables on the other side. is that possible? Thanks

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 11 de Abr. de 2011
factor() might help.

Aider
Aider el 13 de Oct. de 2020
Editada: Aider el 13 de Oct. de 2020
Try this, create a dummy variable "x" so you can use the collect command. Then substitute x by K1*K2
%Misc Intializations
syms K2 K1 s x
%Plant characteristics
T=.1;
Wn=2.5;
z=.3;
%Controller
C=K2*expand((s+2)^2)/expand((s+10)*(s+100));
%Actuator
A=10/(s+10);
%Plant
P=K1*(T*s+1)/(s^2+2*Wn*z*s+Wn^2);
%Closed Loop TF
YcY=C*A*P/(1+C*A*P);
%Characteristic
KLs=expand(C*A*P);
subs(collect(subs(KLs,K1*K2,x),x),x,K1*K2)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by