Extracting a symbolic variable (rearranging symbolic equation)

5 ビュー (過去 30 日間)
Tim
Tim 2011 年 4 月 11 日
編集済み: Aider 2020 年 10 月 13 日
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 件のコメント
Mech Princess
Mech Princess 2012 年 7 月 20 日
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

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 4 月 11 日
factor() might help.

Aider
Aider 2020 年 10 月 13 日
編集済み: Aider 2020 年 10 月 13 日
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)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by