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

4 次查看(过去 30 天)
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 个评论
Paul
Paul 2021-5-11
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).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 PID Controller Tuning 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by