您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 华科材院大二上工控matlab实验代码
实验一:1、num=[129];den=[12472];model=tf(num,den)model=s^2+2s+9-----------------------------s^4+2s^3+4s^2+7s+22、num=7*[25];den=conv(conv([100],[32]),conv([278],[45]));model=tf(num,den)model=14s+35---------------------------------------------24s^6+130s^5+277s^4+254s^3+80s^23、sys1=tf([29],[472]);sys2=tf([16],[171]);sys=series(sys1,sys2)sys=2s^2+21s+54----------------------------------4s^4+35s^3+55s^2+21s+24、g1=tf([29],[472]);g2=tf([16],[271]);g=parallel(g1,g2)g=8s^3+63s^2+109s+21----------------------------------8s^4+42s^3+57s^2+21s+25、g1=tf([29],[265]);g=feedback(g1,1)g=2s+9----------------2s^2+8s+146、sys=tf([279],[112243722]);t=0:0.1:10;y=step(sys,t);plot(t,y);grid7、g1=tf([2],[10.62]);t=0:0.01:20;y=step(g1,t);plot(t,y);[ym,km]=max(y);line(t(km),ym,'marker','.','markeredgecolor','r','markersize',20);ystr=['ymax=',sprintf('%1.6g',ym)];tstr=['tmax=',sprintf('%1.4g',t(km))];text(t(km),ym,{ystr,tstr});ttt=t(find(abs(y-1)0.05));ts=max(ttt);holdon;plot(ts,0.95,'bo','markersize',10);holdoff;text(ts+1.5,0.95,['ts=',num2str(ts)]);grid;8、t=0:0.01:0.8;g1=[50];tao=0;g2=[0.051+50*tao50];g3=tf(g1,g2);tao=0.0125;g2=[0.051+50*tao50];g4=tf(g1,g2);tao=0.025;g2=[0.051+50*tao50];g5=tf(g1,g2);[y1,T]=impulse(g3,t);[y1a,T]=step(g3,t);[y2,T]=impulse(g4,t);[y2a,T]=step(g4,t);[y3,T]=impulse(g5,t);[y3a,T]=step(g5,t);subplot(121),plot(T,y1,'--',T,y2,'-.',T,y3,'-')legend('tao=0','tao=0.0125','tao=0.025')xlabel('t(sec)'),ylabel('x(t)');gridon;subplot(122),plot(T,y1a,'--',T,y2a,'-.',T,y3a,'-')legend('tao=0','tao=0.0125','tao=0.025')xlabel('t(sec)'),ylabel('x(t)');gridon;t=0:0.01:20;g1=[1];tao=0.1;g2=[12*tao1];g3=tf(g1,g2);tao=0.3;g2=[12*tao1];g4=tf(g1,g2);tao=0.5;g2=[12*tao1];g5=tf(g1,g2);tao=0.7;g2=[12*tao1];g6=tf(g1,g2);tao=1;g2=[12*tao1];g7=tf(g1,g2);tao=2;g2=[12*tao1];g8=tf(g1,g2);tao=3;g2=[12*tao1];g9=tf(g1,g2);[y1,T]=step(g3,t);[y2,T]=step(g4,t);[y3,T]=step(g5,t);[y4,T]=step(g6,t);[y5,T]=step(g7,t);[y6,T]=step(g8,t);[y7,T]=step(g9,t);subplot(121),plot(T,y1,'--',T,y2,'-.',T,y3,'-',T,y4,'--',T,y5,'-.',T,y6,'-',T,y7,'--');subplot(122),plot(T,y2,'-');gridon;[ym,km]=max(y2);line(T(km),ym,'marker','.','markeredgecolor','r','markersize',20);ystr=['ymax=',sprintf('%1.6g',ym)];tstr=['tp=',sprintf('%1.4g',T(km))];text(T(km)+1,ym-0.05,{ystr,tstr});ttt=T(find(abs(y2-1)0.05));ts=max(ttt);holdon;plot(ts,1.05,'bo','markersize',10);holdoff;text(ts+1.2,1.05,['ts=',num2str(ts)]);tt=T(find(abs(y2-1)0.003));tr=min(tt);holdon;plot(tr,1,'bo','markersize',10);holdoff;text(tr,0.9,['tr=',num2str(tr)]);t=0:0.01:20;forw=0.1:0.1:1ga=[w*w];gb=[1ww*w];g=tf(ga,gb);sys=step(g,t);holdon;plot(t,sys);holdoff;end;t=0:0.01:20;g=tf(0.49,[10.70.49]);y=step(g,t);plot(t,y);gridon;[ym,km]=max(y);line(t(km),ym,'marker','.','markeredgecolor','r','markersize',20);ystr=['ymax=',sprintf('%1.6g',ym)];tstr=['tp=',sprintf('%1.4g',t(km))];text(t(km)+0.25,ym,{ystr,tstr});ttt=t(find(abs(y-1)0.05));ts=max(ttt);holdon;plot(ts,1.05,'bo','markersize',10);holdoff;text(ts+0.4,1.05,['ts=',num2str(ts)]);tt=t(find(abs(y-1)0.003));tr=min(tt);holdon;plot(tr,1,'bo','markersize',10);holdoff;text(tr,0.96,['tr=',num2str(tr)]);9、g=tf([4,-12],[1,5,9,13,12]);h=tf(1,[0.01,1]);G=feedback(g,h);impulse(g),figure,impulse(G)10、num=1;den=[10.13];t=[0:0.1:100];u=sin(2*3.14*50*t);lsim(num,den,u,t)实验二1、g=tf(1000,conv([112],[16]));nyquist(g)Nyquist图保卫(-1,j0)点两次,而开环系统中没有不稳定的极点,系统是不稳定的。进一步求闭环传涵的根得G=feedback(g,1);roots(G.den{1})ans=-12.6714+0.0000i2.8357+8.4749i2.8357-8.4749i有两个根位于右半平面,由此验证该系统是不稳定的。2、num=3.5;den=[1232];bode(num,den)3、fortao=0.1:0.2:0.9g=tf(1,[12*tao1]);holdon;bode(g);holdoff;end;gridlegend('tao=0.1','tao=0.3','tao=0.5',’tao=0.7’,’tao=0.9’);forw=0.1:0.2:0.9g=tf(w*w,[12*0.707*ww*w]);holdon;bode(g);holdoff;end;grid;legend('w=0.1','w=0.3','w=0.5','w=0.7','w=0.9');4、g=tf(3.5,[1232]);g_close=feedback(g,1);[gm,pn,wcg,wcp]=margin(g)gm=1.1433pn=7.1688wcg=1.7323wcp=1.6541step(g_close)5、num=100*conv([15],[15]);den=conv([11],[119]);g=tf(num,den);[gm,pm,wcg,wcp]=margin(g)gm=Infpm=85.4365wcg=NaNwcp=100.3285g_close=feedback(g,1);step(g_close)实验六1、num=20;den=[0.510];w=logspace(-1,2,500);g=tf(num,den);[mag,phase,w]=bode(g,w);[gm,pm,wcg,wcp]=margin(mag,phase,w);phi=(45+5-pm)*pi/180;alpha=(1-sin(phi))/(1+sin(phi));m=10*log10(alpha)*ones(length(w),1);semilogx(w,20*log10(mag(:)),w,m);grid;wmmin=w(find(20*log10(mag(:))m));wmin=max(wmmin);wmmax=w(find(20*log10(mag(:))m));wmax=min(wmmax);wc=(wmin+wmax)/2;T=1/sqrt(alpha)/wc;alphaT=T*alpha;sys=tf([T1],[alphaT1]);figure;bode(sys,w);syss=series(g,sys);[mag,phase,w]=bode(syss,w);[Gm,Pm,Wcg,Wcp]=margin(mag,phase,w);holdon;bode(syss,w);bode(g,w);holdoff;gridon;legend('校正后','校正前');text(1,0,['相位裕度=',num2str(Pm)]);2、num=20;den=[120];w=logspace(-1,2,500);g=tf(num,den);[mag,phase,w]=bode(g,w);[gm,pm,wcg,wcp]=margin(mag,phase,w);
本文标题:华科材院大二上工控matlab实验代码
链接地址:https://www.777doc.com/doc-6140361 .html