自控原理MATLAB实验学校:*********作者:李新华TransferFcn20.2s+1StepScope5Scope4Scope3Scope2Scope1ScopeIntegrator21sIntegrator11sIntegrator1sGain80.5Gain71Gain65Gain52Gain40.01Gain310Gain22Gain110Gain2Derivative1du/dtDerivativedu/dtAdd2Add1Add图一典型环节的阶跃响应simulink仿真图图二比例环节图三积分环节图四比例积分环节图五比例微分环节图六比例微积分环节图七惯性环节程序一:wn=10;kosi=[0,0.25,0.5,0.7,1,2];%阻尼比分别为0,0.25,0.5,0.7,1,2num=wn^2;figure(1)holdonfori=1:6;%求阻尼比分别为0,0.25,0.5,0.7,1,2时的单位阶跃响应den=[1,2*kosi(i)*wn,wn^2];t=[0:0.01:4];step(num,den,t)endholdofftitle('stepresponse')%标题为stepresponse00.511.522.533.5400.20.40.60.811.21.41.61.82stepresponseTime(sec)Amplitudeξ=0ξ=0.25ξ=0.5ξ=0.7ξ=1ξ=2图八ωn一定ξ变化时系统单位阶跃响应曲线程序二:wn=[2,4,6,8,10,12];%以2为最小值,12为最大值,步长为2kosi=0.707;figure(1)holdonfori=1:6num=wn(i)^2;%分别求wn为2,4,6,8,10,12时的单位阶跃响应den=[1,2*kosi*wn(i),wn(i)^2];t=[0:0.01:4];step(num,den,t)endholdofftitle('stepresponse')%标题为stepresponse00.511.522.533.5400.20.40.60.811.21.4stepresponseTime(sec)Amplitudeωn=2ωn=4ωn=6ωn=8ωn=10ωn=12图九ξ一定ωn变化时系统单位阶跃响应曲线程序一:num=[10];den=[0.020.310];[nc,dc]=cloop(num,den,-1);sys=tf(nc,dc);step(sys)StepResponseTime(sec)Amplitude02468101200.20.40.60.811.21.41.61.8System:sysPeakamplitude:1.7Overshoot(%):69.9Attime(sec):0.607System:sysRiseTime(sec):0.205System:sysSettlingTime(sec):7.51System:sysFinalValue:1图一原系统的单位阶跃响应曲线程序二:G=tf([10],[0.020.310]);%建立开环系统模型figure(1)%绘制伯德图bode(G);BodeDiagramFrequency(rad/sec)-150-100-50050Magnitude(dB)System:GGainMargin(dB):3.52Atfrequency(rad/sec):7.07ClosedLoopStable?Yes10-1100101102103-270-225-180-135-90Phase(deg)System:GPhaseMargin(deg):11.4DelayMargin(sec):0.0349Atfrequency(rad/sec):5.72ClosedLoopStable?Yes图二原系统的Bode图程序三:G=tf([10],[0.020.310]);%建立开环系统模型figure(1)nyquist(G);%绘制奈奎斯特图NyquistDiagramRealAxisImaginaryAxis-3-2.5-2-1.5-1-0.50-40-30-20-10010203040System:GPhaseMargin(deg):11.4DelayMargin(sec):0.0349Atfrequency(rad/sec):5.72ClosedLoopStable?YesSystem:GGainMargin(dB):3.52Atfrequency(rad/sec):7.07ClosedLoopStable?YesSystem:GPeakgain(dB):280Frequency(rad/sec):1e-013图三原系统的Nyquist曲线程序四:num=[10];den=[0.020.310];sys=tf(nc,dc);rltool(sys)-30-25-20-15-10-50510-20-15-10-505101520RootLocusEditor(C)RealAxisImagAxis图四原系统的根轨迹程序五:clearnum=[10];den=conv([1,0],conv([0.1,1],[0.2,1]));phm=45+5;phmd=-180+phm;w=logspace(-1,2,800)'[mag,phase]=bode(num,den,w);mag1=20*log10(mag)fori=find((phase=-128)&(phase=-132))disp([imag1(i)phase(i)w(i)])endii=input('enterindexfordesiredabd...')t=100/(w(ii)*(sqrt(1+0.01*w(ii)^2))*(sqrt(1+0.04*w(ii)^2)))/w(ii)beta=(w(ii)*(sqrt(1+0.01*w(ii)^2))*(sqrt(1+0.04*w(ii)^2)))/10%运行结果:365.000011.5857-128.04992.3265366.000011.4933-128.34962.3467367.000011.4006-128.65132.3671368.000011.3076-128.95482.3877369.000011.2144-129.26032.4084370.000011.1209-129.56772.4293371.000011.0272-129.87702.4504372.000010.9332-130.18822.4717373.000010.8389-130.50132.4931374.000010.7443-130.81642.5148375.000010.6494-131.13332.5366376.000010.5543-131.45222.5586377.000010.4588-131.77302.5809enterindexfordesiredabd...373ii=373t=13.9700beta=0.2871程序六:G1=tf([0.2871*13.971],[13.97,1]);%建立开环系统模型,绘制校正装置的bode图figure(1)bode(G1);-12-10-8-6-4-20Magnitude(dB)10-310-210-1100101-40-30-20-100Phase(deg)BodeDiagramFrequency(rad/sec)图五校正装置的Bode图程序七:G1=tf([0.2871*13.971],[13.97,1]);num2=[10];den2=conv([1,0],conv([0.1,1],[0.2,1]));G2=tf(num2,den2);G=G1*G2;figure(2)%绘制校正后的bode图margin(G);%并确定校正后系统的幅值裕度和相角裕度-150-100-50050100Magnitude(dB)10-310-210-1100101102103-270-225-180-135-90Phase(deg)BodeDiagramGm=13.9dB(at6.88rad/sec),Pm=45.3deg(at2.5rad/sec)Frequency(rad/sec)图六校正后系统的Bode图程序八:num3=conv([10],[0.2871*13.971]);den3=conv(conv([13.97,1],[1,0]),conv([0.1,1],[0.2,1]));[nc,dc]=cloop(num3,den3,-1);sys=tf(nc,dc);figure(3)step(sys);01234567891000.20.40.60.811.21.4StepResponseTime(sec)Amplitude图七校正后系统的单位阶跃响应曲线