How to represent 2 inputs 4 outputs closed loop state space system as a MATLAB code? please help!

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?!

 채택된 답변

Paul
Paul 2021년 5월 11일
편집: Paul 2021년 5월 11일
According to
doc connect
the last two arguments to connect() should each be a char or cell arrays of char, in the order inputs,outputs. So in your second code change to
CLry = connect(G,C_a,C_r,Sum_phi,Sum_beta,{'r_phi','r_beta'},{'phi','beta'});

댓글 수: 3

Thank you very much! The problem is solved.
I simulated the system and get the effect of u1 and u2 inputs over x1, x2, x3 and x4 separately. So the simulation of step() command showed me the effect of u1 over x1 and the effect of u2 over x1 as two different graphs. How can I sum the effect of u1 over x1 and effect of u2 over x1 and represent it in one graph in order to simulate the dynamics of the system?
If I didn't make the issue clear: I want to input r_phi=0.1 and r_beta=0.01 at the same time and see the response of x1 in total.
If i undersand your code, the state x1 = beta, and beta is an output of CLry. You can use the step() command on CLry to get beta in response to a unit step inputs in r_phi and r_beta. Let's call these outputs beta_from_rphi and beta_from_rbeta. Then you can combine beta_from_rphi and beta_from_rbeta in the appropriate way using the superposition property of LTI systems.
Alternatively, you can use:
doc lsim
Or you can try both and show that they give the same answer (to within numerical noise).
Very thankful to you! Your answers are very helpful. Wish you all the best!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Control System Toolbox에 대해 자세히 알아보기

질문:

2021년 5월 10일

댓글:

2021년 5월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by