东北大学11控制系统计算机辅助设计——MATLAB语言与应用控制系统计算机辅助设计1控制系统计算机辅助设计第一部分1functiondx=lorenzeq(t,x)dx=[-x(2)-x(3);x(1)+0.2*x(2);0.2+(x(1)-5.7)*x(3);]x0=[0;0;0];[t,y]=ode45('lorenzeq',[0,100],x0);plot(t,y)figure;plot3(y(:,1),y(:,2),y(:,3)),grid,控制系统计算机辅助设计22function[y,yeq]=f2a(x)yeq=[];y=4*x(1)^2+x(2)^2-4;Aeq=[];Beq=[];A=[];B=[];xm=[0;0];xM=[];x0=[0;0];f1=inline('x(1)^2-2*x(1)+x(2)');[x,f]=fmincon(f1,x0,A,B,Aeq,Beq,xm,xM,'f2a');x',fans=1.00000f=-13(a)s=tf('s');G=(s^3+4*s+2)/s^3/(s^2+2)/[(s^2+1)^3+2*s+5]Transferfunction:s^3+4s+2------------------------------------------------------s^11+5s^9+9s^7+2s^6+12s^5+4s^4+12s^3(b)z=tf('z',0.1);H=(z^2+0.568)/(z-1)/(z^2-0.2*z+0.99)Transferfunction:z^2+0.568-----------------------------z^3-1.2z^2+1.19z-0.99Samplingtime:0.14A=[010;001;-5-4-13];B=[0;0;2];C=[100;000;000];D=[0];G=ss(A,B,C,D);Ga=x1x2x3x1010x2001x3-5-4-13b=u1x10控制系统计算机辅助设计3x20x32c=x1x2x3y1100y2000y3000d=u1y10y20y30Continuous-timemodel.G=tf(G)Transferfunctionfrominputtooutput...2#1:----------------------s^3+13s^2+4s+5#2:0#3:0GG=zpk(G)Zero/pole/gainfrominputtooutput...2#1:----------------------------------(s+12.72)(s^2+0.2836s+0.3932)#2:0#3:0根据微分方程也可以直接写出传递函数模型:num=[2];den=[1,13,4,5];G=tf(num,den);GTransferfunction:2----------------------s^3+13s^2+4s+5GG=zpk(G)Zero/pole/gain:2----------------------------------(s+12.72)(s^2+0.2836s+0.3932)控制系统计算机辅助设计45num=[1,2];den=[1,1,0.16];H=tf(num,den,'Ts',1);HTransferfunction:z+2--------------z^2+z+0.16Samplingtime:16functionH=feedback(G1,G2,key)ifnargin==2;key=-1;end,H=G1/(sym(1)-key*G1*G2);H=simple(H);symsJKpKis;gc=(Kp*s+Ki)/s;g=(s+1)/(J*s^2+2*s+5);gg=feedback(g*gc,1)gg=feedback(g*gc,1)gg=((Ki+Kp*s)*(s+1))/(J*s^3+(Kp+2)*s^2+(Ki+Kp+5)*s+Ki)7(a)s=tf('s');G=(211.87*s+317.64)/(s+20)/(s+94.34)/(s+0.1684);Gc=(169.6*s+400)/s/(s+4);Hs=1/(0.01*s+1);GG=feedback(G*Gc,Hs)Transferfunction:359.3s^3+3.732e004s^2+1.399e005s+127056-----------------------------------------------------------------0.01s^6+2.185s^5+142.1s^4+2444s^3+4.389e004s^2+1.399e005s+127056zpk(GG)Zero/pole/gain:35933.152(s+100)(s+2.358)(s+1.499)--------------------------------------------------------------------------(s^2+3.667s+3.501)(s^2+11.73s+339.1)(s^2+203.1s+1.07e004)(b)z=tf('z');G=(35786.7*z^-1+108444)/[(z^-1+4)*(z^-1+20)*(z^-1+74.04)];控制系统计算机辅助设计5Gc=1/(z^-1-1);H=1/(0.5*z^-1-1);GG=feedback(G*Gc,H)Transferfunction:-108444z^6+1.844e004z^5+1.789e004z^4------------------------------------------------------------------1.144e005z^6+2.876e004z^5+274.2z^4+782.4z^3+47.52z^2+0.5zSamplingtime:unspecifiedzpk(GG)Zero/pole/gain:-0.94821z^4(z-0.5)(z+0.33)-------------------------------------------------------------z(z+0.3035)(z+0.04438)(z+0.01355)(z^2-0.11z+0.02396)Samplingtime:unspecified8s=tf('s');c1=feedback(1/(s+1)*s/(s^2+2),(4*s+2)/(s+1)^2);c2=feedback(1/s^2,50);G=feedback(c1*c2,(s^2+2)/(s^3+14))Transferfunction:s^6+2s^5+s^4+14s^3+28s^2+14s---------------------------------------------------------------------------------s^10+3s^9+55s^8+175s^7+300s^6+1323s^5+2656s^4+3715s^3+7732s^2+5602s+14009s=tf('s');G=(s+1)^2*(s^2+2*s+400)/(s+5)^2/(s^2+3*s+100)/(s^2+3*s+2500);G1=c2d(G,0.01)Transferfunction:4.716e-005z^5-0.0001396z^4+9.596e-005z^3+8.18e-005z^2-0.0001289z+4.355e-005-----------------------------------------------------------------z^6-5.592z^5+13.26z^4-17.06z^3+12.58z^2-5.032z+0.8521Samplingtime:0.01step(G1)控制系统计算机辅助设计6G2=c2d(G,0.1)Transferfunction:0.0003982z^5-0.0003919z^4-0.000336z^3+0.0007842z^2-0.000766z+0.0003214-----------------------------------------------------------------z^6-2.644z^5+4.044z^4-3.94z^3+2.549z^2-1.056z+0.2019Samplingtime:0.1step(G2)G3=c2d(G,1)Transferfunction:8.625e-005z^5-4.48e-005z^4+6.545e-006z^3+1.211e-005z^2-3.299e-006z+1.011e-007-----------------------------------------------------------------z^6-0.0419z^5-0.07092z^4-0.0004549z^3+0.002495z^2-3.347e-005z+1.125e-007控制系统计算机辅助设计7Samplingtime:1step(G3)10(a)G=1/(s^3+2*s^2+s+2);pzmap(G)系统极点均在虚轴左侧,系统稳定控制系统计算机辅助设计8(b)G=1/(6*s^4+3*s^3+2*s^2+s+1);pzmap(G)系统极点在虚轴右侧侧,系统不稳定(c)G=1/(s^4+s^3-3*s^2-s+2);pzmap(G)系统极点在虚轴右侧侧,系统不稳定11(a)z=tf('z',0.1);H=(-3*z+2)/(z^3-0.2*z^2-0.25*z+0.05);控制系统计算机辅助设计9pzmap(H)系统所有极点均在单位圆内,所以系统稳定(b)z=tf('z',0.1);H=(3*z^2-0.39*z-0.09)/(z^4-1.7*z^3+1.04*z^2+0.268*z+0.024);pzmap(H)系统所有极点不全单位圆内,所以系统不稳定12A=[-0.20.5000;0-0.51.600;00-14.385.80;000-33.3100;0000-10];B=[0;0;0;0;30];C=[00000];G=ss(A,B,C,0)a=控制系统计算机辅助设计10x1x2x3x4x5x1-0.20.5000x20-0.51.600x300-14.385.80x4000-33.3100x50000-10b=u1x10x20x30x40x530c=x1x2x3x4x5y100000d=u1y10Continuous-timemodel.pzmap(G)系统所有极点均在虚轴左侧,所以系统稳定或eig(G)ans=-0.2000-0.5000-14.3000-33.3000-10.0000控制系统计算机辅助设计11极点均在左半轴,所以系统稳定13数值解:f=@(t,x)[-5*x(1)+2*x(2);-4*x(2);-3*x(1)+2*x(2)-4*x(3)-x(4);-3*x(1)+2*x(2)-4*x(4)];t_final=10;x0=[1200];[t,x]=ode45(f,[0,t_final],x0);plot(t,x)解析解function[Ga,Xa]=ss_augment(G,cc,dd,X)G=ss(G);Aa=G.a;Ca=G.c;Xa=X;Ba=G.b;D=G.d;if(length(dd)0&sum(abs(dd)1e-5)),if(abs