看了一下,修正了一系列问题得到如下结果;
%Integration Separation PID Controller
clear all;
close all;
ts=15;
%Delay plant
sys=tf([1],[50,1],'inputdelay',45);
d=45/ts+1;%d:delay
dsys=c2d(sys,ts,'zoh');
[num,den]=tfdata(dsys,'v')
nb=length(num)-1;
na=length(den)-1;
u_1=0;u_2=0;u_3=0;u_4=0;u_5=1;
y_1=0;y_2=0;y_3=0;
error_1=0;error_2=0;
ei=0;
L=100;
y=zeros(1,L);
u=zeros(1,L);
yd=16*[ones(1,L)];
for k=7:1:100
time(k)=k*ts;
%Delay plant
%y(k)=-den(2)*y_1+num(2)*u_5;
y(k)=num*u(k-d:-1:k-d-nb)'-den(1,2:na+1)*y(k-1:-1:k-na)';
%I separation
%yd(k)=16;
error(k)=yd(k)-y(k);