%%%%%%%%%%%%%%%%%%% 初始化 %%%%%%%%%%%%%%%%%5
clear all;
close all;
G=10000;
N=10;
w=2.5*(1-2.*rand(N,1));
%ci=1-(2.*rand(2,10));
ci=3.*(1-(2.*rand(2,10)));
di=0.5.*rand(1,10);
E=0;
%%%%%%%%%%%%%%%%%%% 非线性系统 %%%%%%%%%%%%%%%%%%%%%%
%u1=2.*(1-2.*rand(1,800));
y_1=0;
ts=0.2;
%testx(3,10000)=0;
for k=1:1:G
time(k)=k*ts;
u1(k)=1.0*(cos(2*pi*k*ts/250));
%u1(k)=3.25-3*square((2*pi/150)*k);
yout1(k)=1.5*y_1/(1+y_1^2)+0.3*cos(y_1)+1.2*u1(k);
%u_1=u1(k);
%y_1=yout1(k);
%testx(:,k)=[u1(k);yout1(k);y_1];
u_1=u1(k);
y_1=yout1(k);
end
testx=[u1;yout1];
%%%%%%%%%%%%%%%%%%%% 训练开始 %%%%%%%%%%%%%%%%%%%%%
for k=1:1:G
for j=1:1:10
h(j)=exp(-norm(testx(:,k)-ci(:,j))^2/(2*di(j)*di(j)));
end
ymout1(k)=h*w;
%%%%%%%%%%%%%%%%%%%%%% 参数的调整 %%%%%%%%%%%%%%%%%%%%
d_w=0;
for j=1:1:N
d_w(j,1)=0.2.*(yout1(k)-ymout1(k))*h(j);
end
w=w+d_w;
d_di=0;
for j=1:1:N
d_di(j)=0.2.*(yout1(k)-ymout1(k))*w(j)*h(j)*(di(j)^-3)*norm(testx(:,k)-ci(:,j))^2;
end
di=di+d_di;
for j=1:1:N;
for i=1:1:2;
d_ci(i,j)=0.2.*(yout1(k)-ymout1(k))*w(j)*h(j)*(testx(i,k)-ci(i,j))*(di(j)^-2);
end
end
ci=ci+d_ci;
end
%figure(1);
%plot(time,yout1,'r',time,ymout,'b');
%%%%%%%%%%%%%%%%%%%%%%%%%%% 测试 %%%%%%%%%%%%%%%%%%%%%%%%%5
y_2=0;
ts=0.1;
for k=1:1:G
time(k)=k*ts;
u(k)=1.0*(cos(2*pi*k*ts/250));
%u(k)=3.25-3*square((2*pi/150)*k);
yout(k)=1.5*y_1/(1+y_1^2)+0.3*cos(y_1)+1.2*u(k);
%x(:,k)=[u(k);yout(k);y_2];
u_1=u(k);
y_1=yout(k);
end
x=[u;yout];
for k=1:1:G
for j=1:1:N
h(j)=exp(-norm(x(:,k)-ci(:,j))^2/(2*di(j)*di(j)));
end
ymout(k)=h*w;
end
for k=1:1:G
error(k)=yout(k)-ymout(k);
E=E+error(k);
end
E=abs(E)/G;
figure(1);
plot(time,yout,'r',time,ymout,'b')
alvarocfc
- 粉丝: 125
- 资源: 1万+
最新资源
- working-shell脚本入门——流程控制
- ThinkCMF-mysql安装
- BigData-Notes-sqoop的安装与配置
- C语言-leetcode题解之28-implement-strstr.c
- C语言-leetcode题解之27-remove-element.c
- C语言-leetcode题解之26-remove-duplicates-from-sorted-array.c
- C语言-leetcode题解之24-swap-nodes-in-pairs.c
- C语言-leetcode题解之22-generate-parentheses.c
- C语言-leetcode题解之21-merge-two-sorted-lists.c
- java-leetcode题解之Online Stock Span.java
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈