模糊RBF神经网络——程序
本帖最后由 牛小贱 于 2015-3-6 11:06 编辑%模糊RBF神经网络
%参考刘金琨老师的智能控制
clc
clear all
ts=0.001;
y_1=0; u_1=0;
w=rands(25,1)/10; w_1=w; w_2=w;
c=[-4 -2 0 2 4;
-4 -2 0 2 4].'; %五条规则,两个输入
B=10*ones(5,2); B_1=B;B_2=B;
c_1=c; c_2=c_1;
for K=1:1:10000
%xitong
u(K)=0.4*sin(4*pi*K*ts);
y(K)=u_1^3+y_1/(1+y_1^2);
%--------------------------------------%
input0(K,:)=;
%%
input=input0(K);
for n=1:1:size(c,1)
f2(n,:)=exp(-(input.'-c(n,:)).^2./(B(n,:)).^2);
end
f3=f2(:,1)*f2(:,2).';
f3=reshape(f3,1,25).';
output=w.'*f3;
%%
ym(K)=output;
Error=y(K)-ym(K);
w=w_1+0.01*Error*f3+0.01*(w_1-w_2); w_2=w_1; w_1=w;
deta2=-Error*w.'*f3;
for n=1:1:size(c,1)
d_b(n,:)=2*(input.'-c(n,:)).*((B(n,:)).^-3);
end
B=B_1+0.01*d_b+0.01*(B_1-B_2); B_2=B_1; B_1=B;
for n=1:1:size(c,1)
d_c(n,:)=-2*(input.'-c(n,:)).*((B(n,:)).^-2);
end
c=c_1+0.01*d_c+0.01*(c_1-c_2); c_2=c_1; c_1=c;
time(K)=K*ts;
u_1=u(K);
y_1=y(K);
end
figure(1);plot(time,y,'b',time,ym,'r');grid on
%figure(2);plot(time,Error,'r');grid on
{:{39}:} {:{51}:} 学习一下,顶一个
页:
[1]