您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 经营企划 > 大林算法程序和PID程序
´óÁÖËã·¨clcclearts=0.5;G=tf([1],[0.41],'inputdelay',0.76);%±»¿Ø¶ÔÏ󴫵ݺ¯Êýdsys1=c2d(G,ts,'z');%¹ãÒå±»¿Ø¶ÔÏóÂö³å´«µÝº¯Êý[num1,den1]=tfdata(dsys1,'v');%ÆÚÍû±Õ»·´«µÝº¯Êýsys2=tf([1],[0.151],'inputdelay',0.76)dsys2=c2d(sys2,ts,'z');%ÆÚÍû±Õ»·Âö³å´«µÝº¯Êýdsys=1/dsys1*dsys2/(1-dsys2);%´óÁÖËã·¨¿ØÖÆÆ÷Âö³å´«µÝº¯Êý[num,den]=tfdata(dsys,'v');u1=0.0;u2=0.0;u3=0.0;u4=0;u5=0;y1=0;error1=0;error2=0;error3=0;fork=1:1:50time(k)=k*ts;rin(k)=1.0;yout(k)=-den1(2)*y1+num1(2)*u2+num1(3)*u3;%±»¿Ø¶ÔÏóÊä³öerror(k)=rin(k)-yout(k);u(k)=(num(1)*error(k)+num(2)*error1+num(3)*error2+num(4)*error3...%¿ØÖÆÆ÷Êä³ö-den(3)*u1-den(4)*u2-den(5)*u3-den(6)*u4-den(7)*u5)/den(2);u5=u4;u4=u3;u3=u2;u2=u1;u1=u(k);y1=yout£¨k£©error3=error2;error2=error1;error1=error(k);endsubplot(2,1,1);plot(time,rin,'b',time,yout,'r');xlabel('time(s)');ylabel('rin,yout');title('DALINmethod');gridon********************************************************************************************PID¿ØÖÆÆ÷Êä³öu1=0.0;u2=0.0;u3=0.0;u4=0;u5=0;y1=0;error1=0;error2=0;error3=0;ei=0;fork=1:1:50time(k)=k*ts;rin(k)=1.0;yout(k)=-den1(2)*y1+num1(2)*u2+num1(3)*u3;error(k)=rin(k)-yout(k);ei=ei+error(k)*ts;u(k)=1.0*error(k)+0.1*(error(k)-error1)/ts+0.50*ei;%PID¿ØÖÆÆ÷Êä³öy1=yout(k);error3=error2;error2=error1;error1=error(k);u3=u2;u2=u1;u1=u(k);y1=yout(k);error3=error2;error2=error1;error1=error(k);endsubplot(2,1,2)plot(time,rin,'b',time,yout,'g');xlabel('time(s)');ylabel('rin,yout');title('PIDmethod');gridon
本文标题:大林算法程序和PID程序
链接地址:https://www.777doc.com/doc-5595759 .html