MATLAB: Creating a transfer function from a determinant

transfer function

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]);

Best Answer

How about:
[num,den] = numden(G_vel)
G_vel_tf = tf(sym2poly(num), sym2poly(den))
Related Question