优秀的编程知识分享平台

网站首页 > 技术文章 正文

基于MATLAB的BP神经网络预测计算App

nanyue 2025-06-13 15:42:53 技术文章 3 ℃

BP(BackPropagation)神经网络可用于数据的预测,是经常使用的预测方法之一。之前介绍了基于MATLAB的guide制作的BP神经网络预测计算GUI界面,但是随着MATLAB版本的更新,之后的版本不再支持guide制作的GUI界面,因此我基于MATLAB App Designer将BP神经网络预测计算GUI界面修改成App,这样可以兼容2016之后的版本,也不受最新版本的限制。

基于MATLAB的BP神经网络预测计算APP的运行界面如下:

点击加载数据——输入样本数据个数、训练数据个数、预测数据个数、中间层隐藏节点个数、网络输入维度、网络输出维度,x轴坐标名称、y轴坐标名称——点击开始计算即可出现结果,同时会在当前文件夹下生成预测数据的excel文件和相应图片bmp、fig、jpg和pdf格式文件。需要基于MATLAB的BP神经网络预测计算APP的完整程序,可以进行打赏后截图(50元及以上),点击微信公众号云龙派的“联系掌门”按键进行联系,或者在微信公众号云龙派里内回复截图,几小时内会回复。界面编程不易,还请见谅!App Designer编程不易,还请见谅!


1.基于MATLAB的BP神经网络预测计算APP举例计算

样本数据


Step1:点击BpyuceApp.mlappinstall文件,在MATLAB中双击安装APP,点击安装到我的APP。

Step2:在APP 菜单栏中找到我的app中的BpyuceApp,双击运行出App主界面。

Step3:点击加载数据,选择数据excel文件,并点击确定。

Step4:输入参数。

Step5:点击开始计算。

Step6:运行结果文件生成。


2.App主要程序如下

classdef Bpyuceapp < matlab.apps.AppBase


    % Properties that correspond to app components
    properties (Access = public)
        UIFigure         matlab.ui.Figure
        BpPanel          matlab.ui.container.Panel
        Panel            matlab.ui.container.Panel
        Button           matlab.ui.control.Button
        Label_3          matlab.ui.control.Label
        EditField        matlab.ui.control.NumericEditField
        Label_4          matlab.ui.control.Label
        EditField_2      matlab.ui.control.NumericEditField
        Label_5          matlab.ui.control.Label
        EditField_3      matlab.ui.control.NumericEditField
        Label_6          matlab.ui.control.Label
        EditField_4      matlab.ui.control.NumericEditField
        Label_7          matlab.ui.control.Label
        EditField_5      matlab.ui.control.NumericEditField
        Label_8          matlab.ui.control.Label
        EditField_6      matlab.ui.control.NumericEditField
        xEditFieldLabel  matlab.ui.control.Label
        xEditField       matlab.ui.control.EditField
        yEditFieldLabel  matlab.ui.control.Label
        yEditField       matlab.ui.control.EditField
        Panel_2          matlab.ui.container.Panel
        Button_2         matlab.ui.control.Button
        Button_3         matlab.ui.control.Button
        Button_4         matlab.ui.control.Button
        Panel_3          matlab.ui.container.Panel
        UIAxes           matlab.ui.control.UIAxes
        UIAxes_2         matlab.ui.control.UIAxes
        UITable          matlab.ui.control.Table
        UITable_2        matlab.ui.control.Table
        UITable_3        matlab.ui.control.Table
        Label            matlab.ui.control.Label
        BpLabel          matlab.ui.control.Label
        Label_2          matlab.ui.control.Label
    end


    % Callbacks that handle component events
    methods (Access = private)


        % Button pushed function: Button_4
        function Button_4Pushed(app, event)
            closereq;
        end


        % Button pushed function: Button_3
        function Button_3Pushed(app, event)
            app.EditField.Value = 0;
            app.EditField_2.Value = 0;
            app.EditField_3.Value = 0;
            app.EditField_4.Value = 0;
            app.EditField_5.Value = 0;
            app.EditField_6.Value = 0;
            app.xEditField.Value = " ";
            app.yEditField.Value = " ";
            app.UITable.Data = [];%矩阵数据使表格为空
            app.UITable_2.Data = [];
            app.UITable_3.Data = [];
            try
                delete(allchild(app.UIAxes));
                delete(allchild(app.UIAxes_2));
            end
        end


        % Button pushed function: Button
        function ButtonPushed(app, event)
            %加载数据  使用全局变量传递加载的数据
            global data
            [filename,pathname,filterindex]=uigetfile({'*.xlsx';'*.txt';'*.*'},'打开数据');
            if ~filename
                return;
            end
            str1=[pathname,filename];
            if (filename==0 & pathname==0)
                msgbox('您没有选择文件,请重新选择!','打开文件出错','error');
            else
                %                 data=xlsread (strcat([pathname filename])); %strcat是组成路径的。
                data = xlsread (strcat([pathname filename]));
                msgbox('打开及读取数据完毕!','确认','warn');
            end
        end

本文内容来源于网络,仅供参考学习,如内容、图片有任何版权问题,请联系处理,24小时内删除。


作 者 | 郭志龙

编 辑 | 郭志龙
校 对 | 郭志龙

Tags:

最近发表
标签列表