matlab提取传递函数系数,温度控制传递函数_增量式PID系数_MATLAB仿真

clear all;

close all;

ts=0.1;

sys=tf([5],[8,1],'inputdelay',10);

dsys=c2d(sys,ts,'zoh');

[num,den]=tfdata(dsys,'v');

u_1=0;u_2=0;u_3=0;u_4=0;u_5=0;

y_1=0;y_2=0;y_3=0;

error_1=0;error_2=0;

x=[0,0,0];

for k=1:1:200

time(k)=k*ts;

yout(k)=-den(2)*y_1+num(2)*u_5;

rin(k)=1;

error(k)=rin(k)-yout(k);

kp=1;

ki=0;

kd=0;

du(k)=kp*x(1)+kd*x(2)+ki*x(3);

u(k)=u_1+du(k);

u_5=u_4;u_4=u_3;u_3=u_2;u_2=u_1;u_1=u(k);

y_3=y_2;y_2=y_1;y_1=yout(k);

x(1)= error(k)-error_1;

x(2)= error(k)-2*error_1+error_2;

x(3)= error(k);

error_2=error_1;

error_1=error(k);

end

hold on

hold on

plot(time,rin,'g',time,yout,'r','linewidth',2)

xlabel('time(s)')

ylabel('rin,yout')

ts=0.1;

sys=tf([5],[8,1],'inputdelay',10);

dsys=c2d(sys,ts,'zoh');

[num,den]=tfdata(dsys,'v');

u_1=0;u_2=0;u_3=0;u_4=0;u_5=0;

y_1=0;y_2=0;y_3=0;

error_1=0;error_2=0;

x=[0,0,0];

for k=1:1:200

你可能感兴趣的:(matlab提取传递函数系数)