Extracting a symbolic variable (rearranging symbolic equation)

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 Kommentar

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

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Aider
Aider am 13 Okt. 2020
Bearbeitet: Aider am 13 Okt. 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)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

Tim
am 11 Apr. 2011

Bearbeitet:

am 13 Okt. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by