資源簡(jiǎn)介
基于MATLAB編寫的單神經(jīng)元PID的代碼,可以運(yùn)行,稍作改動(dòng)就能使用
代碼片段和文件信息
%Single?Neural?Adaptive?PID?Controller?
clear?all;?
close?all;?
x=[000]‘;?
xiteP=0.40;?
xiteI=0.35;?
xiteD=0.40;?
%Initilizing?kpki?and?kd?
wkp_1=0.10;?
wki_1=0.10;?
wkd_1=0.10;?
%wkp_1=rand;?
%wki_1=rand;?
%wkd_1=rand;?
error_1=0;?
error_2=0;?
y_1=0;y_2=0;y_3=0;?
u_1=0;u_2=0;u_3=0;?
ts=0.001;?
for?k=1:1:1000?
time(k)=k*ts;?
rin(k)=0.5*sign(sin(2*2*pi*k*ts));?
yout(k)=0.368*y_1+0.26*y_2+0.1*u_1+0.632*u_2;?
error(k)=rin(k)-yout(k);?
%Adjusting?Weight?Value?by?hebb?learning?algorithm?
M=4;?
if?M==1?%No?Supervised?Heb?learning?algorithm?
wkp(k)=wkp_1+xiteP*u_1*x(1);?%P?
wki(k)=wki_1+xiteI*u_1*x(2);?%I?
wkd(k)=wkd_1+xiteD*u_1*x(3);?%D?
K=0.06;?
elseif?M==2?%Supervised?Delta?learning?algorithm?
wkp(k)=wkp_1+xiteP*error(k)*u_1;?%P?
wki(k)=wki_1+xiteI*error(k)*u_1;?%I?
wkd(k)=wkd_1+xiteD*error(k)*u_1;?%D?
K=0.12;?
elseif?M==3?%Supervised?Heb?learning?algorithm?
wkp(k)=wkp_1+xiteP*error(k)*u_1*x(1);?%P?
wki(k)=wki_1+xiteI*error(k)*u_1*x(2);?%I?
w
評(píng)論
共有 條評(píng)論