creating a transfer function from a determinant

19 views (last 30 days)
Hey Guys,
So I'm trying to create a transfer function in matlab using the determinants and state space equations via linear algebra. The thing is I can manually pull the coefficients out of the results and plug them into the tf command, but I have to fiddle with the input numbers to get the desired result, so I'd rather not have to manually plug that in every time. Any suggestions?
syms s
m = 5;
k = 10;
b = 50;
m_c = 0.1*m;
k_c = k;
b_c = b;
R_wc = 10;
T_c = 10;
H = (b_c*R_wc)/(b_c*R_wc+T_c^2);
V_1 = det([-(H*T_c^2-b)/R_wc -k -H*T_c^2/(m_c*R_wc) -H*k_c*T_c^2/(b_c*R_wc); ...
1 s 0 0; ...
-H*T_c^2/R_wc 0 s-H*T_c^2/(m_c*R_wc) -H*k_c*T_c^2/(b_c*R_wc); ...
-H*T_c^2/(b_c*R_wc) 0 -H*T_c^2/(m_c*b_c*R_wc) s-(k_c*H*T_c^2-H*R_wc)/(b_c^2*R_wc)]);
V_2 = det([H*T_c/R_wc -k -H*T_c^2/(m_c*R_wc) -H*k_c*T_c^2/(b_c*R_wc); ...
0 s 0 0; ...
H*T_c/R_wc 0 s-H*T_c^2/(m_c*R_wc) -H*k_c*T_c^2/(b_c*R_wc); ...
H*T_c/(b_c*R_wc) 0 -H*T_c^2/(m_c*b_c*R_wc) s-(k_c*H*T_c^2-H*R_wc)/(b_c^2*R_wc)]);
den = det([s-(H*T_c^2-b*R_wc)/(m*R_wc) -k -H*T_c^2/(m_c*R_wc) -H*k_c*T_c^2/(b_c*R_wc); ...
1/m s 0 0; ...
-H*T_c^2/(m*R_wc) 0 s-H*T_c^2/(m_c*R_wc) -H*k_c*T_c^2/(b_c*R_wc); ...
-H*T_c^2/(m*b_c*R_wc) 0 -H*T_c^2/(m_c*b_c*R_wc) s-(k_c*H*T_c^2-H*R_wc)/(b_c^2*R_wc)]);
G_vel = vpa(V_1/den,10)
G_vel_tf = tf([4.257211935 242.9349118 271.8731897 0.07907120546],[-1.0 19.8925608 269.8083056 54.43899276 0.01581424109]);

Accepted Answer

David Wilson
David Wilson on 2 Dec 2019
How about:
[num,den] = numden(G_vel)
G_vel_tf = tf(sym2poly(num), sym2poly(den))
  1 Comment
Michael Gibson
Michael Gibson on 2 Dec 2019
Thanks for answering, but I managed to figure it out while I was waiting. Here's what I ended up doing:
v_1 = coeffs(V_1);
v_1 = double(fliplr(v_1));
v_2 = coeffs(V_2);
v_2 = double(fliplr(v_2));
Den = coeffs(den);
Den = double(fliplr(Den));
G_vel_tf = tf([v_1],[Den*m]);
G_F_c = vpa(V_2/den,10);
G_F_C_tf = tf([v_2],[Den*m]);
bode(G_vel_tf)
bode(G_F_C_tf)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!