%% 基于Elman神经网络的电力负荷预测模型研究
%% 清空环境变量
clc;
clear all
close all
nntwarn off;
%% 数据载入
load data;
a=data;
%% 选取训练数据和测试数据
for i=1:6
p(i,:)=[a(i,:),a(i+1,:),a(i+2,:)];
end
% 训练数据输入
p_train=p(1:5,:);
% 训练数据输出
t_train=a(4:8,:);
% 测试数据输入
p_test=p(6,:);
% 测试数据输出
t_test=a(9,:);
% 为适应网络结构 做转置
p_train=p_train';
t_train=t_train';
p_test=p_test';
%% 网络的建立和训练
% 利用循环,设置不同的隐藏层神经元个数
nn=[7 11 14 18];
for i=1:4
threshold=[0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1];
% 建立Elman神经网络 隐藏层为nn(i)个神经元
net=newelm(threshold,[nn(i),3],{'tansig','purelin'});
% 设置网络训练参数
net.trainparam.epochs=1000;
net.trainparam.show=20;
% 初始化网络
net=init(net);
% Elman网络训练
net=train(net,p_train,t_train);
% 预测数据
y=sim(net,p_test);
% 计算误差
error(i,:)=y'-t_test;
end
%% 通过作图 观察不同隐藏层神经元个数时,网络的预测效果
plot(1:1:3,error(1,:),'-ro','linewidth',2);
hold on;
plot(1:1:3,error(2,:),'b:x','linewidth',2);
hold on;
plot(1:1:3,error(3,:),'k-.s','linewidth',2);
hold on;
plot(1:1:3,error(4,:),'c--d','linewidth',2);
title('Elman预测误差图')
set(gca,'Xtick',[1:3])
legend('7','11','14','18','location','best')
xlabel('时间点')
ylabel('误差')
hold off;
Eno1.rar_Elman_elman预测_load forecasting_神经网络 负荷 预测_负荷预测
版权申诉
85 浏览量
2022-09-23
11:31:02
上传
评论
收藏 916B RAR 举报
alvarocfc
- 粉丝: 109
- 资源: 1万+
最新资源
- 基于SHT25温湿度传感器、FREERTOS、STM32F103C8T6、LCD1602温湿度采集显示系统proteus仿真设计
- C# 屏幕放大取色器 随时随地获取屏幕像素颜色
- 下载安装这个软件.apk
- 【数据集详细解释及案例分析】数据集详细解释及案例分析
- 基于SHT71温湿度传感器、STM32F103C8T6、LCD1602温湿度采集显示系统proteus仿真设计
- 基于TH02温湿度传感器、STM32F103C8T6、LCD1602、FREERTOS的温湿度采集系统proteus仿真设计
- 【TCP-IP协议详细解释及案例分析】TCP-IP协议详细解释及案例分析
- 一文搞懂 LSTM(长短期记忆网络).rar
- 【autosar简介及基本案例解析】autosar简介及基本案例解析
- java模拟斗地主洗牌发牌
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈