www.pudn.com > BubianjuWork.rar > chap7f2.m
function [u]=chap7f2(u1,u2,u3,u4)
global s
persistent w x1 x2 x3 w1 w2 w3
N=300;
C=5;
if u3==0
w=zeros(N+C,1);
w1=w;
w2=w;
dw=w;
end
alfa=0.04;
if s==1
smin=0;
smax=1;
elseif s==2
smin=-0.5;
smax=0.5;
elseif s==3
smin=-0.5;
smax=0.5;
end
xite=0.1;
dvi=(smax-smin)/(N-1);
for i=1:1:C
v(i)=smin;
end
for i=C+1:1:C+N
v(i)=v(i-1)+dvi;
end
for i=N+C+1:1:N+2*C
v(i)=smax;
end
rin=u1;
for i=1:1:N+C
if rin>=v(i)&rin<=v(i+C)
a(i)=1;
else
a(i)=0;
end
end
errork=u2;
un=a*w1;
up=u4;
u=up+un;
if u>=10
u=10;
end
if u<=-10
u=-10;
end
if s==1|s==3
dw=a*xite*up/C;
elseif s==2
dw=xite*up/C;
end
w=w1+dw+alfa*(w1-w2);
w3=w2;
w2=w1;
w1=w;