《控制系统仿真与CAD》实验课程报告一、实验教学目标与基本要求上机实验是本课程重要的实践教学环节。
实验的目的不仅仅是验证理论知识,更重要的是通过上机加强学生的实验手段与实践技能,掌握应用MATLAB/Simulink 求解控制问题的方法,培养学生分析问题、解决问题、应用知识的能力和创新精神,全面提高学生的综合素质。
通过对MATLAB/Simulink进行求解,基本掌握常见控制问题的求解方法与命令调用,更深入地认识和了解MATLAB语言的强大的计算功能与其在控制领域的应用优势。
上机实验最终以书面报告的形式提交,作为期末成绩的考核内容。
二、题目及解答第一部分:MATLAB 必备基础知识、控制系统模型与转换、线性控制系统的计算机辅助分析1.>>f=inline('[-x(2)-x(3);x(1)+a*x(2);b+(x(1)-c)*x(3)]','t','x','flag','a','b','c');[t,x]=ode45( f,[0,100],[0;0;0],[],0.2,0.2,5.7);plot3(x(:,1),x(:,2),x(:,3)),grid,figure,plot(x(:,1),x(:,2)), grid2.>>y=@(x)x(1)^2-2*x(1)+x(2);ff=optimset;rgeScale='off';ff.TolFun=1e-30;ff.Tol X=1e-15;ff.TolCon=1e-20;x0=[1;1;1];xm=[0;0;0];xM=[];A=[];B=[];Aeq=[];Beq=[];[ x,f,c,d]=fmincon(y,x0,A,B,Aeq,Beq,xm,xM,@wzhfc1,ff)Warning: Options LargeScale = 'off' and Algorithm ='trust-region-reflective' conflict.Ignoring Algorithm and running active-set algorithm. To runtrust-region-reflective, setLargeScale = 'on'. To run active-set without this warning, useAlgorithm = 'active-set'.> In fmincon at 456Local minimum possible. Constraints satisfied.fmincon stopped because the size of the current search direction is less thantwice the selected value of the step size tolerance and constraints aresatisfied to within the selected value of the constraint tolerance.<stopping criteria details>Active inequalities (to within options.TolCon = 1e-20):lower upper ineqlin ineqnonlin2x =1.00001.0000f =-1.0000c =4d =iterations: 5funcCount: 20lssteplength: 1stepsize: 3.9638e-26algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'firstorderopt: 7.4506e-09constrviolation: 0message: [1x766 char]3.(a) >> s=tf('s');G=(s^3+4*s+2)/(s^3*(s^2+2)*((s^2+1)^3+2*s+5))G =s^3 + 4 s + 2------------------------------------------------------s^11 + 5 s^9 + 9 s^7 + 2 s^6 + 12 s^5 + 4 s^4 + 12 s^3Continuous-time transfer function.(b)>> z=tf('z',0.1);H=(z^2+0.568)/((z-1)*(z^2-0.2*z+0.99))H =z^2 + 0.568-----------------------------z^3 - 1.2 z^2 + 1.19 z - 0.99Sample time: 0.1 secondsDiscrete-time transfer function.4.>> A=[0 1 0;0 0 1;-15 -4 -13];B=[0 0 2]';C=[1 00];D=0;G=ss(A,B,C,D),Gs=tf(G),Gz=zpk(G)G =a =x1 x2 x3x1 0 1 0x2 0 0 1x3 -15 -4 -13b =u1x1 0x2 0x3 2c =x1 x2 x3y1 1 0 0d =u1y1 0Continuous-time state-space model.Gs =2-----------------------s^3 + 13 s^2 + 4 s + 15 Continuous-time transfer function.Gz =2---------------------------------(s+12.78) (s^2 + 0.2212s + 1.174) Continuous-time zero/pole/gain model.5.设采样周期为0.01s>> z=tf('z',0.01);H=(z+2)/(z^2+z+0.16) H =z + 2--------------z^2 + z + 0.16Sample time: 0.01 secondsDiscrete-time transfer function.6.>> syms J Kp Ki s;G=(s+1)/(J*s^2+2*s+5);Gc=(Kp*s+Ki)/s;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));H=1/(0.01*s+1);GG=feedback(G*Gc,H),Gd=ss(GG),Gz=zpk(GG)GG =359.3 s^3 + 3.732e04 s^2 + 1.399e05 s + 127056----------------------------------------------------------------0.01 s^6 + 2.185 s^5 + 142.1 s^4 + 2444 s^3 + 4.389e04 s^2 + 1.399e05 s + 127056Continuous-time transfer function.Gd =a =x1 x2 x3 x4 x5 x6x1 -218.5 -111.1 -29.83 -16.74 -6.671 -3.029x2 128 0 0 0 0 0x3 0 64 0 0 0 0x4 0 0 32 0 0 0x5 0 0 0 8 0 0x6 0 0 0 0 2 0b =u1x1 4x2 0x3 0x4 0x5 0x6 0c =x1 x2 x3 x4 x5 x6y1 0 0 1.097 3.559 1.668 0.7573d =u1y1 0Continuous-time state-space model.Gz =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.07e04) Continuous-time zero/pole/gain model.(b)设采样周期为0.1s>>z=tf('z',0.1);G=(35786.7*z^2+108444*z^3)/((1+4*z)*(1+20*z)*(1+74.04*z));Gc= z/(1-z);H=z/(0.5-z);GG=feedback(G*Gc,H),Gd=ss(GG),Gz=zpk(GG)GG =-108444 z^5 + 1.844e04 z^4 + 1.789e04 z^3----------------------------------------------------------------1.144e05 z^5 +2.876e04 z^4 + 274.2 z^3 + 782.4 z^2 + 47.52 z + 0.5Sample time: 0.1 secondsDiscrete-time transfer function.Gd =a =x1 x2 x3 x4 x5 x1 -0.2515 -0.00959 -0.1095 -0.05318 -0.01791x2 0.25 0 0 0 0x3 0 0.25 0 0 0x4 0 0 0.125 0 0x5 0 0 0 0.03125 0b =u1x1 1x2 0x3 0x4 0x5 0c =x1 x2 x3 x4 x5y1 0.3996 0.6349 0.1038 0.05043 0.01698d =u1y1 -0.9482Sample time: 0.1 secondsDiscrete-time state-space model.Gz =-0.94821 z^3 (z-0.5) (z+0.33)----------------------------------------------------------(z+0.3035) (z+0.04438) (z+0.01355) (z^2 - 0.11z + 0.02396)Sample time: 0.1 secondsDiscrete-time zero/pole/gain model.8.>>s=tf('s');g1=1/(s+1);g2=s/(s^2+2);g3=1/s^2;g4=(4*s+2)/(s+1)^2;g5=50;g6=(s^2+2) /(s^3+14);G1=feedback(g1*g2,g4);G2=feedback(g3,g5);GG=3*feedback(G1*G2,g6) GG =3 s^6 + 6 s^5 + 3 s^4 + 42 s^3 + 84 s^2 + 42 s---------------------------------------------------------------------------s^10 + 3 s^9 + 55 s^8 + 175 s^7 + 300 s^6 + 1323 s^5 + 2656 s^4 + 3715 s^3 + 7732 s^2 + 5602 s + 1400Continuous-time transfer function.9.>>s=tf('s');T0=0.01;T1=0.1;T2=1;G=(s+1)^2*(s^2+2*s+400)/((s+5)^2*(s^2+3*s+100 )*(s^2+3*s+2500));Gd1=c2d(G,T0),Gd2=c2d(G,T1),Gd3=c2d(G,T2),step(G),figure,st ep(Gd1),figure,step(Gd2),figure,step(Gd3)Gd1 =4.716e-05 z^5 - 0.0001396 z^4 + 9.596e-05 z^3 + 8.18e-05 z^2 - 0.0001289 z + 4.355e-05----------------------------------------------------------------z^6 - 5.592 z^5 + 13.26 z^4 - 17.06 z^3 + 12.58 z^2 - 5.032 z + 0.8521Sample time: 0.01 secondsDiscrete-time transfer function.Gd2 =0.0003982 z^5 - 0.0003919 z^4 - 0.000336 z^3 + 0.0007842 z^2 - 0.000766 z + 0.0003214----------------------------------------------------------------z^6 - 2.644 z^5 + 4.044 z^4 - 3.94 z^3 + 2.549 z^2 - 1.056 z + 0.2019Sample time: 0.1 secondsDiscrete-time transfer function.Gd3 =8.625e-05 z^5 - 4.48e-05 z^4 + 6.545e-06 z^3 + 1.211e -05 z^2 - 3.299e-06 z + 1.011e-07---------------------------------------------------------------z^6 - 0.0419 z^5 - 0.07092 z^4 - 0.0004549 z^3 + 0.002495 z^2 - 3.347e-05 z + 1.125e-07Sample time: 1 secondsDiscrete-time transfer function.10.(a)>> G=tf(1,[1 2 1 2]);eig(G),pzmap(G) ans =-2.0000-0.0000 + 1.0000i-0.0000 - 1.0000i系统为临界稳定。