📄 chaotic_prediction3.m
字号:
clear;clc;close all
%% chaotic signal generation
A = 4;
x = zeros(1,1500) + 0.1;
for k = 1:1499
x(k+1) = A * x(k) * (1-x(k));
end
% plot(x, 'DisplayName', 'x', 'YDataSource', 'x'); figure(gcf);
%% train and test sets
train_set = x(1,1:1200);
%% training the FNN
C1 = 0.05*ones(3,3);
W1 = 0.05*ones(3,3);
f1 = rand(1,3);
M1 = ones(1,3);
% load gooddata.mat;
C=C1;
W=W1;
f=f1;
M=M1;
alpha = 0.1;
Error = [];
e = 1;
E = 0;
q = 1;
while e > 0.001
outputdata = [];
desireddata = [];
e = 0;
e = E;
for p = 3:1199
a = 0;
b = 0;
input = [train_set(p),train_set(p-1),train_set(p-2)];
desired_output = train_set(p+1);
%output computation:
for j = 1:3
for i = 1:3
M(j) = M(j) * exp ( -((input(i) - C(i,j)) / W(i,j))^2 );
end
a = a + f(j) * M(j);
b = b + M(j);
end
y = a / b;
outputdata = [outputdata y];
desireddata = [desireddata desired_output];
%weight correction:
for j=1:3
f(j) = f(j) - (alpha * ((y - desired_output) / b) * M(j)) ;
for i=1:3
T1 = alpha * ((y - desired_output) / b) * (f(j) - y) * M(j) * (2 * (input(i) - C(i,j))/(W(i,j)).^2);
T2 = alpha * ((y - desired_output) / b) * (f(j) - y) * M(j) * (2 * (input(i) - C(i,j).^2)/(W(i,j)).^3);
W(i,j) = W(i,j) - T2;
C(i,j) = C(i,j) - T1;
end
end
%Error computation:
e = e + (y - desired_output);
M=ones(1,3);
E = e;
end
%normalizing error:
e = sqrt((1/(1200*q))*e.^2);
q = q + 1
Error = [Error,e];
end
figure; plot (Error)
figure; plot (outputdata,'r'); hold on; plot (desireddata)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -