1、y1,T=impulse(G1,t);y1a,T=step(G1,t);y2,T=impulse(G2,t);y2a,T=step(G2,t);y3,T=impulse(G3,t);y3a,T=step(G3,t);subplot(121),plot(T,y1,-,T,y2,-.,T,y3,-)legend(tao=0,tao=0.0125tao=0.025xlabel(t(sec),ylabel(x(t);grid on;subplot(122),plot(T,y1a,T,y2a,T,y3a,输出曲线: 单位脉冲相应曲线 单位阶跃响应曲线一、 利用MATLAB求系统的瞬态性能指标 clear
2、 all;1;u=sin(2*pi.*t);G=tf(nG,dG);y=lsim(G,u,t);plot(t,u,t,y,t,u-y,linewidth,1)u(t)xo(t)e(t)grid; 系统响应及其误差曲线 close all; % t=0:0.001:1; yss=1;dta=0.02; nG=50; tao=0; tao=0.0125; tao=0.025;G3=tf(nG,dG); y1=step(G1,t);y2=step(G2,t);y3=step(G3,t); r=1;while y1(r)1-dta & y1(s)1+dta;s=s-1; ts1=(s-1)*0.001
3、;while y2(r)y3(s) ts2=(s-1)*0.001;while y3(r) y3(s)=-3;n=n+1;Wb=w(n);M0 Wb Mr Wr输出的频域特征量:6.0212 20.0923 8.6942 7.9248第五章实验:利用MATLAB分析系统的稳定性一、利用MATLAB分析系统的相对稳定性 源程序: den=conv(1 5,1 1 0);K=10;num1=K;Gm1 Pm1 Wg1 Wc1=margin(num1,den);K=100;num2=K;mag, phase,w=bode(num2,den);Gm2 Pm2 Wg2 Wc2=margin(mag, p
4、hase,w);20*log10(Gm1) Pm1 Wg1 Wc1;20*log10(Gm2) Pm2 Wg2 Wc2输出计算结果: 6.0212 20.0923 8.6942 7.9248 9.5424 25.3898 2.2361 1.2271 -10.4576 -23.5463 2.2361 3.9010第六章实验:利用MATLAB进行系统校正一、未校正前的Bode图曲线 k=20;numg=1;deng=0.5 1 0;num,den=series(k,1,numg,deng);w=logspace(-1,2,200);mag,phase,w=bode(tf(num,den),w);G
5、m,Pm,Wcg,Wcp=margin(mag,phase,w);Phi=(50-Pm+5)*pi/180;alpha=(1-sin(Phi)/(1+sin(Phi);M=10*log10(alpha)*ones(length(w),1);semilogx(w,20*log10(mag(:),w,M);二、校正后的Bode图曲线numgc=0.23 1;dengc=0.055 1;nums,dens=series(numgc,dengc,numg,deng);num,den=series(k,1,nums,dens);bode(tf(num,den),w);title(相位裕度=,num2str(Pm);