代写 C clear; clc

clear; clc
m 500;
L 25;
Iy 1300;
Xudot 130;
Xu 94;
Zwdot 110;
Zw 4.7e2;
Zqdot 120;
Zq 9.5e2;
Mqdot 120300;
Mq 1.1e3;
Mwdot 140300;
Mw 320;
Xs 13;
Xb 13;
Umax 3e6;
N 6;
M 3;
P 3;
A 0 1 0 0 0 0; 0 XumXudot 0 0 0 0; 0 0 0 1 0 0; 0 0 0 ZwIyMqZqdotMw
B 0 0 0; 1mXudot 0 0; 0 0 0; 0 IyMqZqdotXsmZwdotIyMqZqdotMwdot
C 1 0 0 0 0 0; 0 0 1 0 0 0; 0 0 0 0 1 0;
D 0;
sys ssA,B,C,D
sys A
x1 x2 x3 x4 x5 x6 x1 0 1 0 0 0 0 x2 00.188 0 0 0 0 x3 0 0 0 1 0 0 x4 0 0 0 0.9398 0 1.9 x5 0 0 0 0 0 1 x6 0 0 00.2909 0 1
B
u1 u2 u3
x1 0 0 0
x2 0.002 0 0
x3 0 0 0
x4 0 0.002 0.002
x5 0 0 0
x6 0 0.000303 0.000303
C
x1 x2 x3 x4 x5 x6
y1 1 0 0 0 0 0
y2 0 0 1 0 0 0
y3 0 0 0 0 1 0
D
u1 u2 u3
y1 0 0 0
y2 0 0 0
y3 0 0 0
1

Continuoustime statespace model.
sysrminrealsys;
Determine by Comparing Rank of A
if ranksys.Aranksysr.A
dispThe statespace model is a mininmum realization
else
dispThe statespace model is Not a minimum realization
end
The statespace model is a mininmum realization
This openloop system is completely controllable
for i1:M
for ji:M
sysisys:,i,j;
if rankctrbsysi.A, sysi.BN
if ij
fprintfThe subset i is completely controllablen, i
else
fprintfThe subset i, i is completely controllablen, i, j
end
else
if ij
if rankctrbsys.A,sys.BN
dispThis openloop system is completely controllable
else
dispThis openloop system is Not completely controllable
end
fprintfThe subset i is Not completely controllablen, i
else
fprintfThe subset i, i is Not completely controllablen, i, j
end
end end
end
The subset 1 is Not completely controllable
The subset 1, 2 is Not completely controllable
The subset 1, 3 is Not completely controllable
The subset 2 is Not completely controllable
The subset 2, 3 is Not completely controllable
The subset 3 is Not completely controllable
poleseigA;
wnabspoles2pi;
zetacosanglepoles;
openLoop tablepoles,wn,zeta,VariableNames,Pole,Frequency,Damping;
dispopenLoop
2

Pole Frequency Damping

0 0 1
0 0 1
1.7139 0.27277 1
0.22592 0.035956 1
0 0 1
0.18799 0.029919 1
X0 50; 100; 350; 300; 45; 0;
y,tinitialsys,X0;
plott,y:,1,t,y:,2,t,y:,3,Linewidth,2;
legendInterpreter, LaTeX,FontSize,14;
xlabelTime s;
ylabelDistance m;
titleOpen Loop Initial Value Response;
axis0 tend 500 700;
setgca,FontSize,12,Linewidth,2;
setgcf, PaperUnits, centimeters;
setgcf, PaperSize, 32 16;
grid on
s1 lsiminfoy:,1,t,SettlingTimeThreshold,0.05
s1 struct with fields: SettlingTime: 15.8175
Min: 50
3

MinTime: 0
Max: 581.3202
MaxTime: 35.8448
designCase 5
switch designCase
case 1 all three control signal torque exceed maximum, however, the settling time is
p211i;
p322i;
p422i;
p533i;
p633i;
case 2 all control signal met the requirement, however, output 1 3 settling time ex
p20.10.1i;
p30.20.2i;
p40.20.2i;
p50.30.3i;
p60.30.3i;
case 3 Both performance requirements are met
p10.20.2i;
p20.20.2i;
p30.30.3i;
p40.30.3i;
p50.40.4i;
p60.40.4i;
case 4 Both performance requirements are met
p10.30.3i;
p20.30.3i;
p30.40.4i;
p40.40.4i;
p50.50.5i;
p60.50.5i;
case 5 Both performance requirements are met
p10.40.4i;
p20.40.4i;
p30.50.5i;
p40.50.5i;
p50.60.6i;
p60.60.6i;
end
GplaceA,B,p1 p2 p3 p4 p5 p6;
uG50; 100; 350; 300; 45; 0;
sysGssABG,B,C,D;
TsstepinfosysG,SettlingTimeThreshold,0.05;
TsTs1,1.SettlingTime,Ts2,2.SettlingTime,Ts3,3.SettlingTime;
if maxTs10 maxabsu3e6
dispBoth performance requirements are met
elseif maxabsu3e6 maxTs10
dispEthier performance requirement is met
elseif maxTs10
dispOne of the settling time is more than 10 seconds
4
designCase5

else
dispOne of the control torque is greater than 2100 Nm
end
Both performance requirements are met
y,t,xinitialsysG,50; 100; 350; 300; 45; 0;
animateauvt,y:,1,y:,2,y:,3
uGx;
subplot2,1,1 output signal
plott,y:,1,t,y:,2,t,y:,3,Linewidth,2
legendInterpreter, LaTeX,FontSize,12
xlabelTime s
ylabelDistance m
titleClose Loop Initial Value Response
axis0 tend 100 200
setgca,FontSize,12,Linewidth,2
setgcf, PaperUnits, centimeters;
setgcf, PaperSize, 16 8;
grid on
subplot2,1,2 control signal
plott,u1,:,t,u2,:,t,u3,:,Linewidth,2
legendInterpreter, LaTeX,FontSize,12
xlabelTime s
ylabelTorque Nm
axis0 tend 10000 10000
setgca,FontSize,12,Linewidth,2
setgcf, PaperUnits, centimeters;
setgcf, PaperSize, 32 16;
grid on
5

6