⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chaotic_prediction4.m

📁 This program is to one-step EEG prediction. it is done by a fuzzy neural network based on a chaotic
💻 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);c
% k=0:.01:15;
% x = sin(k);
    load emotion_p1
%% train and test sets
% train_set = x(1,1:1200);
%% training the FNN
d=10;
C1 = rand(47,d);
W1 = 0.2*ones(47,d);
f = rand(1,d);
M1 = ones(1,d);
% load gooddata.mat;

C=C1;
W=W1;

M=M1;
alpha = 0.1;
Error = [];
e = 1;
E = 0;
q = 1;
% while e > 0.01
for q=1:100
    outputdata = [];
    desireddata = [];
    e = 0;
%     e = E;
    for p = 1:59
        a = 0;
        b = 0;
        input = emotion_p1(p,1:47);
        desired_output = emotion_p1(p,48)/3;
        %output computation:
            for j = 1:d
                for i = 1:47
                    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:d
                    f(j) = f(j) - (alpha * ((y - desired_output) / b) * M(j)) ;
                for i=1:47
                    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 + (1/2)*(y - desired_output)^2;
            M=ones(1,d);
%             E = e;
    end
    
    %normalizing error:
    e = sqrt((1/(59))*e);
    q = q + 1
% W
% C
% f
    Error = [Error,e];
    
    plot(e)
    drawnow 
    
%     hold on;
end
                                          
figure; plot (Error)
figure; plot (outputdata,'r'); hold on; plot (desireddata)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -