各位,能帮我看一下这个程序哪里有错吗,PID增量控制
clear all;
close all;
ts=0.001;
sys=tf(5.235e005,[1,87.35,1.047e004,0]);
dsys=c2d(sys,ts,'z');
[num,den]=tfdata(dsys,'v');
for k=1:1:1500
time(k)=k*ts; % 仿真时间500ms
S=3;
if S==1
kp=0.50;ki=0.001;kd=0.001;
rin(k)=1; %Step Signal
elseif S==2
kp=0.50;ki=0.001;kd=0.001;
rin(k)=sign(sin(2*2*pi*k*ts)); %Square Wave Signal
elseif S==3
kp=1.5;ki=1.0;kd=0.01; %Sine Signal
rin(k)=0.5*sin(2*2*pi*k*ts);
end
end
figure(1);
plot(time,rin,'k',time,yout,'k');
xlabel('time(s)'),ylabel('rin,yout');
yout(k)=-den(2)*y_1-den(3)*y_2-den(4)*y_3+num(2)*u_1+num(3)*u_2+num(4)*u_3; |