ss2tf taking too long

3 Ansichten (letzte 30 Tage)
Ali Almakhmari
Ali Almakhmari am 26 Jul. 2023
Kommentiert: Paul am 26 Jul. 2023
Hi everyone. I am trying to come up with the transfer functions for a very complicated state space representation where the A matrix is 12 by 12, B is 12 by 1, C is 6 by 12, and D is 6 by 1. And all of those matrices use symbolic variables. I am using the ss2tf command but its taking too long. I have been running it for the past 3 hours with no result yet. I hope someone can help or suggest something.
Here is my code to derive the transfer functions in the "SYSTEM" variable:
%Defining the Symbolic Variables
syms ksm ksn ksl wsm wsn wsl Delsm Delsn Delsl DelT m Delgx Delgy Delgz dx
syms tilda_Xu ro tilda_Xv qo tilda_Xw tilda_Xp wo tilda_Xq vo tilda_Xr tilda_Yu tilda_Yv po tilda_Yw uo tilda_Yp tilda_Yq tilda_Yr tilda_Zu tilda_Zv tilda_Zw tilda_Zp tilda_Zq tilda_Zr tilda_Lu tilda_Lv tilda_Lw tilda_Lp tilda_Ixx tilda_Lq tilda_Lr tilda_Mu tilda_Mv tilda_Mw tilda_Iyy tilda_Mp tilda_Mq tilda_Mr tilda_Nu tilda_Nv tilda_Nw tilda_Np tilda_Nq tilda_Nr tilda_Izz
syms tilda_X_delm tilda_X_deln tilda_X_dell tilda_Y_delm tilda_Y_deln tilda_Y_dell tilda_Z_delm tilda_Z_deln tilda_Z_dell tilda_L_delm tilda_L_deln tilda_L_dell tilda_M_delm tilda_M_deln tilda_M_dell tilda_N_delm tilda_N_deln tilda_N_dell mu_sm mu_sn mu_sl
% Defining B Matrix
X = [0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;ksm*wsm^2,0,0;0,ksn*wsn^2,0;0,0,ksl*wsl^2];
Z = [(DelT./m + Delgx);Delgy;Delgz;0;0;0;0;0;0;0;0;0];
U = [Delsm;Delsn;Delsl];
B = X*U + Z; %The B matrix
% Defining A Matrix
F =[tilda_Xu, (ro+tilda_Xv) (-qo+tilda_Xw) tilda_Xp (-wo+tilda_Xq) (vo+tilda_Xr); (-ro+tilda_Yu) tilda_Yv (po+tilda_Yw) (wo+tilda_Yp) tilda_Yq (-uo+tilda_Yr); (qo+tilda_Zu) (-po+tilda_Zv) tilda_Zw (-vo+tilda_Zp) (uo+tilda_Zq) tilda_Zr; tilda_Lu tilda_Lv tilda_Lw tilda_Lp (tilda_Ixx*ro + tilda_Lq) (tilda_Ixx*qo + tilda_Lr); tilda_Mu tilda_Mv tilda_Mw (tilda_Iyy*ro + tilda_Mp) tilda_Mq (tilda_Iyy*po + tilda_Mr); tilda_Nu tilda_Nv tilda_Nw (tilda_Izz*qo + tilda_Np) (tilda_Izz*po + tilda_Nq) tilda_Nr];
G = [tilda_X_delm tilda_X_deln tilda_X_dell; tilda_Y_delm tilda_Y_deln tilda_Y_dell; tilda_Z_delm tilda_Z_deln tilda_Z_dell; tilda_L_delm tilda_L_deln tilda_L_dell; tilda_M_delm tilda_M_deln tilda_M_dell; tilda_N_delm tilda_N_deln tilda_N_dell];
A = [F, G, zeros(6,3);zeros(3,6),zeros(3,3),eye(3);zeros(3,6), [-wsm^2,0,0;0,-wsn^2,0;0,0,-wsl^2], [-2*mu_sm*wsm,0,0;0,-2*mu_sn*wsn,0;0,0,-2*mu_sl*wsl]]; %The A matrix
% Defining C Matrix
H = [0,0,0,1,0,0;0,0,0,0,1,0;0,0,0,0,0,1;tilda_Xu,tilda_Xv,tilda_Xw,tilda_Xp,(tilda_Xq-2*qo*dx) (tilda_Xr-2*ro*dx); (tilda_Yu+tilda_Nu*dx) (tilda_Yv+tilda_Nv*dx) (tilda_Yw+tilda_Nw*dx) (tilda_Yp+(qo+tilda_Izz*qo+tilda_Np)*dx) (tilda_Yq+(po+tilda_Izz*po+tilda_Nq)*dx) (tilda_Yr+tilda_Nr*dx); (tilda_Zu-tilda_Mu*dx) (tilda_Zv-tilda_Mv*dx) (tilda_Zw-tilda_Mw*dx) (tilda_Zp+(ro-tilda_Iyy*ro-tilda_Mp)*dx) (tilda_Zq-tilda_Mq*dx) (tilda_Zr+(po-tilda_Iyy*po+tilda_Mr)*dx)];
J = [0 0 0; 0 0 0; 0 0 0; tilda_X_delm tilda_X_deln tilda_X_dell; (tilda_Y_delm+tilda_N_delm*dx) (tilda_Y_deln+tilda_N_deln*dx) (tilda_Y_dell+tilda_N_dell*dx); (tilda_Z_delm-tilda_M_delm*dx) (tilda_Z_deln-tilda_M_deln*dx) (tilda_Z_dell-tilda_M_dell*dx)];
C = [H J zeros(6,3)]; %The C matrix
% Defining D Matrix
D = [0;0;0;(DelT./m + Delgx);Delgy;Delgz]; %The D matrix
%FINDING THE TRANSFER FUNCTIONS FROM THE STATE SPACES
SYSTEM = ss2tf(A,B,C,D);

Akzeptierte Antwort

Paul
Paul am 26 Jul. 2023
Which version of ss2tf are you using? The one that ships with Matlab
which -all ss2tf
/MATLAB/toolbox/shared/controllib/general/ss2tf.m
doesn't support sym inputs
syms a b c d real
try
ss2tf(a,b,c,d)
catch me
disp('ss2tf failed')
me
end
ss2tf failed
me =
MException with properties: identifier: 'MATLAB:eps:invalidClassName' message: 'CLASSNAME argument must be a class that supports EPS, such as 'double' or 'single'.' cause: {} stack: [4×1 struct] Correction: []
In any case, we can always use the formula directly without resorting to ss2tf
syms s
H(s) = c/(s*eye(size(a))-a)*b + d
H(s) = 
Whether or not such an approach is tenable and yields a useful result depends on the underlying system. There may be other options as well.
  2 Kommentare
Ali Almakhmari
Ali Almakhmari am 26 Jul. 2023
I have the same version of ss2tf you have: /MATLAB/toolbox/shared/controllib/general/ss2tf.m. I tried the H(s) = c/(s*eye(size(a))-a)*b + d and it looks like its taking too long as well, is this normal?
Paul
Paul am 26 Jul. 2023
If you're using the same version of ss2tf, then I don't understand why it's not throwing an error when presented with symbolic inputs. I suspect, but don't know, that eventually it will throw an error if you wait long enough.
Keep in mind that you're asking for a 12th order transfer function with symbolic coefficeints, which, in general, is going to be very messy. Look at the characteristic polynomial for just the upper 3x3 of the A matrix
%Defining the Symbolic Variables
syms ksm ksn ksl wsm wsn wsl Delsm Delsn Delsl DelT m Delgx Delgy Delgz dx
syms tilda_Xu ro tilda_Xv qo tilda_Xw tilda_Xp wo tilda_Xq vo tilda_Xr tilda_Yu tilda_Yv po tilda_Yw uo tilda_Yp tilda_Yq tilda_Yr tilda_Zu tilda_Zv tilda_Zw tilda_Zp tilda_Zq tilda_Zr tilda_Lu tilda_Lv tilda_Lw tilda_Lp tilda_Ixx tilda_Lq tilda_Lr tilda_Mu tilda_Mv tilda_Mw tilda_Iyy tilda_Mp tilda_Mq tilda_Mr tilda_Nu tilda_Nv tilda_Nw tilda_Np tilda_Nq tilda_Nr tilda_Izz
syms tilda_X_delm tilda_X_deln tilda_X_dell tilda_Y_delm tilda_Y_deln tilda_Y_dell tilda_Z_delm tilda_Z_deln tilda_Z_dell tilda_L_delm tilda_L_deln tilda_L_dell tilda_M_delm tilda_M_deln tilda_M_dell tilda_N_delm tilda_N_deln tilda_N_dell mu_sm mu_sn mu_sl
% Defining B Matrix
X = [0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;ksm*wsm^2,0,0;0,ksn*wsn^2,0;0,0,ksl*wsl^2];
Z = [(DelT./m + Delgx);Delgy;Delgz;0;0;0;0;0;0;0;0;0];
U = [Delsm;Delsn;Delsl];
B = X*U + Z; %The B matrix
% Defining A Matrix
F =[tilda_Xu, (ro+tilda_Xv) (-qo+tilda_Xw) tilda_Xp (-wo+tilda_Xq) (vo+tilda_Xr); (-ro+tilda_Yu) tilda_Yv (po+tilda_Yw) (wo+tilda_Yp) tilda_Yq (-uo+tilda_Yr); (qo+tilda_Zu) (-po+tilda_Zv) tilda_Zw (-vo+tilda_Zp) (uo+tilda_Zq) tilda_Zr; tilda_Lu tilda_Lv tilda_Lw tilda_Lp (tilda_Ixx*ro + tilda_Lq) (tilda_Ixx*qo + tilda_Lr); tilda_Mu tilda_Mv tilda_Mw (tilda_Iyy*ro + tilda_Mp) tilda_Mq (tilda_Iyy*po + tilda_Mr); tilda_Nu tilda_Nv tilda_Nw (tilda_Izz*qo + tilda_Np) (tilda_Izz*po + tilda_Nq) tilda_Nr];
G = [tilda_X_delm tilda_X_deln tilda_X_dell; tilda_Y_delm tilda_Y_deln tilda_Y_dell; tilda_Z_delm tilda_Z_deln tilda_Z_dell; tilda_L_delm tilda_L_deln tilda_L_dell; tilda_M_delm tilda_M_deln tilda_M_dell; tilda_N_delm tilda_N_deln tilda_N_dell];
A = [F, G, zeros(6,3);zeros(3,6),zeros(3,3),eye(3);zeros(3,6), [-wsm^2,0,0;0,-wsn^2,0;0,0,-wsl^2], [-2*mu_sm*wsm,0,0;0,-2*mu_sn*wsn,0;0,0,-2*mu_sl*wsl]]; %The A matrix
% Defining C Matrix
H = [0,0,0,1,0,0;0,0,0,0,1,0;0,0,0,0,0,1;tilda_Xu,tilda_Xv,tilda_Xw,tilda_Xp,(tilda_Xq-2*qo*dx) (tilda_Xr-2*ro*dx); (tilda_Yu+tilda_Nu*dx) (tilda_Yv+tilda_Nv*dx) (tilda_Yw+tilda_Nw*dx) (tilda_Yp+(qo+tilda_Izz*qo+tilda_Np)*dx) (tilda_Yq+(po+tilda_Izz*po+tilda_Nq)*dx) (tilda_Yr+tilda_Nr*dx); (tilda_Zu-tilda_Mu*dx) (tilda_Zv-tilda_Mv*dx) (tilda_Zw-tilda_Mw*dx) (tilda_Zp+(ro-tilda_Iyy*ro-tilda_Mp)*dx) (tilda_Zq-tilda_Mq*dx) (tilda_Zr+(po-tilda_Iyy*po+tilda_Mr)*dx)];
J = [0 0 0; 0 0 0; 0 0 0; tilda_X_delm tilda_X_deln tilda_X_dell; (tilda_Y_delm+tilda_N_delm*dx) (tilda_Y_deln+tilda_N_deln*dx) (tilda_Y_dell+tilda_N_dell*dx); (tilda_Z_delm-tilda_M_delm*dx) (tilda_Z_deln-tilda_M_deln*dx) (tilda_Z_dell-tilda_M_dell*dx)];
C = [H J zeros(6,3)]; %The C matrix
% Defining D Matrix
D = [0;0;0;(DelT./m + Delgx);Delgy;Delgz]; %The D matrix
syms s
collect(charpoly(A(1:3,1:3),s),s)
ans = 
Even though the A-matrix has a bunch of zeros, the upper left portion is filled, so I'd be surprised if anythying useful could be obtained even by taking advantage of the strucuture, e.g., using a block matrix inverse.
What do you plan to do with this 12th order transfer function even if you can obtain it. Maybe there's an alternative to meet the ultimate goal (unless the ultimate goal is just to see the transfer function in symbolic form).

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by