www.pudn.com > SHIPCONTROL.rar > KTsimulate.m, change:2014-12-18,size:393b


hn=1000; 
delta=3*pi/180; 
r=zeros(1,hn); 
r(1)=0.2; 
r(2)=0.2; 
bosai=zeros(1,hn); 
bosai(1)=0.5; 
 
kp=9; 
kd=4; 
ki=3; 
ka=kp+ki+kd;  kb=kp+2*kd;kc=kd; 
er=5*pi/180; 
 
for t=1:hn 
     
    if t>2 
r(t)=2/3*(delta+ka*(er-bosai(t))-kb*(er-bosai(t-1))+kc*(er-bosai(t-2))) +5/6*r(t); 
    end 
if t>1 
bosai(t)=bosai(t-1)+r(t-1); 
end 
 
 
 
 
plot(bosai(t)),pause(0.01) 
hold on 
 
end