Matlap神经网络语句报错 您所在的位置:网站首页 s1810报错e1 Matlap神经网络语句报错

Matlap神经网络语句报错

#Matlap神经网络语句报错| 来源: 网络整理| 查看: 265

%--用神经网络进行时间序列建模与预测程序

%-(1)预处理

clc;

clear;

%--(2)产生训练样本数据

%--数据来自文件

p=load('郑州pm2.5-4.20.txt')

P=p'; 

for j=1:543

 y(j)=(P(j)-min(P))/(max(P)-min(P)) ;  %归一化处理

end

for i=1:529

    P1(:,i)=[y(i),y(i+1),y(i+2),y(i+3),y(i+4),y(i+5),y(i+6)]';

    T1(i)=y(i+7)

end 

net=newff([0 1;0 1;0 1;0 1;0 1;0 1;0 1],[5,1],{'tansig','logsig'},'trainlngd');

net.trainParam.epochs=200;%迭代步数设置为200

net.trainParam.goal=0.001;%训练精度目标设置为0.001

net.trainParam.lr=0.05;%迭代速度设置为0.05

net=train(net,P1,T1); 

%---------------------------------RBF网络训练语句

%net=newrb(P1,T1,0,1,350);

%---(4)神经网络计算

t1=sim(net,P1);

%---(5)计算残差

e1=T1-t1;

mse(e1)

%----------------------------------------(6)预测

for i=530:536  %7步预测

    P2(:,i)=[y(i),y(i+1),y(i+2),y(i+3),y(i+4),y(i+5),y(i+6)]';

end

T2=y(537:543);

t2=sim(net,P2);

tttt2=t2(530:536);

e2=T2-tttt2;

mse(e2)

 

for i=1:length(t1)

    tt1=t1*(max(P)-min(P))+min(P);

end

for i=1:length(t2)

    tt2=t2*(max(P)-min(P))+min(P);

end

ttt2=tt2(530:536);

m1=P(8:536);

m2=P(537:543);

  mse(m1-tt1)

 mse(m2-ttt2)

 

figure(1)

title('预测数据残差时间序列(还原后)')        %还原后

plot(1:length(ttt2),m2-ttt2,'*-')

ylabel('PM2.5浓度值(μg/m3)')

xlabel('数据序列')

%  figure(5)

%  title('原时间序列“*”与预测时间序列“-”')

%  plot(1:length(P1),m1,'*',1:length(P1),tt1,'-')

%  ylabel('PM2.5浓度值(μg/m3)')

% xlabel('数据序列')

figure(2)

title('原时间序列“*”与预测时间序列“-”')

plot(1:length(ttt2),m2,'*',1:length(ttt2),ttt2,'-')

ylabel('PM2.5浓度值(μg/m3)')

xlabel('数据序列')

 

% IW=net.IW{1,1}

% LW=net.LW{2,1}

% b1=net.b{1,1}

% b2=net.b{2,1}

e264769c178c4fa18a6dc5918533afae.png

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有