Extracting a symbolic variable (rearranging symbolic equation)
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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개)
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)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!