How to represent 2 inputs 4 outputs closed loop state space system as a MATLAB code? please help!
13 views (last 30 days)
Show older comments
I am trying to represent the following closed loop system as a Matlab code. I have tried to follow the example:
however the example used transfer function. And when I replace the transfer function matrix with:
ss(A,B,C,D)
code, Matlab gives the error: (Time units must agree.) when I use the code:
A =
[-0.467 -0.001278 -1 0.04782;
-141.4 -9.798 7.034 0;
33.61 -2.261 -1.005 0;
0 1 0 0];
B = [ 0 0.01308;
128.5 64.26;
-0.5931 -23.73;
0 0];
C = eye(4);
D = [0 0;
0 0;
0 0;
0 0];
G = ss(A,B,C,D);
G.InputName = {'aileron';'rudder'};
G.OutputName = 'y';
D = tunableGain('Decoupler',eye(2));
D.u = 'e';
D.y = {'e_phi';'e_beta'};
C_a = pid(1.23740502206763,2.08998402399655,0.0648471425518328);
C_a.TimeUnit = 'minutes';
C_a.u = 'e_phi'; C_a.y = 'aileron';
C_r = pid(1.48843500027863,5.15386062628497,0.106478981231435);
C_r.TimeUnit = 'minutes';
C_r.u = 'e_beta'; C_r.y = 'rudder';
Sum = sumblk('e=r-y',2);
CLry = connect(G,D,C_a,C_r,Sum,'r','y');
step(CLry);
and gives the error (Input argument 6 is not a dynamic system or has some unspecified I/O names) when I use the code:
A =
[-0.467 -0.001278 -1 0.04782;
-141.4 -9.798 7.034 0;
33.61 -2.261 -1.005 0;
0 1 0 0];
B = [ 0 0.01308;
128.5 64.26;
-0.5931 -23.73;
0 0];
C = eye(4);
D = [0 0;
0 0;
0 0;
0 0];
G = ss(A,B,C,D);
G.u = {'aileron';'rudder'};
G.y = {'beta';'roll';'yaw';'phi'};
C_a = pid(1.23740502206763,2.08998402399655,0.0648471425518328);
C_a.u = 'e_phi'; C_a.y = 'aileron';
C_r = pid(1.48843500027863,5.15386062628497,0.106478981231435);
C_r.u = 'e_beta'; C_r.y = 'rudder';
Sum_phi = sumblk('e_phi=r_phi-phi');
Sum_beta = sumblk('e_beta=r_beta-beta');
CLry = connect(G,C_a,C_r,Sum_phi,Sum_beta,'beta','phi','r_phi','r_beta');
step(CLry);
% what is the mistake I am doing?!

0 Comments
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!