前面也基于MATLAB的guide将logistics模型做出了一个GUI计算系统,只需要简单的导入数据,设置好输入的参数,即可获得对应的图形和数据结果。但是随着MATLAB版本的更新,之后的版本不再支持guide制作的GUI界面,因此我基于MATLAB App Designer将基于MATLAB的logistics模型修改成App,这样可以兼容2016之后的版本,也不受最新版本的限制。
基于MATLAB的logistics模型预测人口App如下:
点击导入数据——输入预测数据的起始年份和终止年份以及x轴坐标和y轴坐标名称——点击开始计算——即可以获得预测的结果数据、误差数据、相对误差数据以及相应的图形文件,并且在当前文件夹自动保存图像文件和excel结果文件。需要App安装包的,可以进行微信公众号云龙派打赏后截图(80元及以上),点击公众号“联系掌门”进行联系,或者在公众号内回复截图,几小时内会回复。界面编程不易,还请见谅!

1.基于MATLAB的logistics模型预测人口App举例计算
数据为某市1978年至2021年的人口数据,利用logistics模型预测该市2022年至2035年的人口数据。

Step1:点击logisticsApp.mlappinstall文件,在MATLAB中双击安装APP,点击安装到我的APP。
Step2:在APP 菜单栏中找到我的app中的logisticsApp,双击运行出App主界面。
Step3:点击加载数据,选择数据excel文件,并点击确定。
Step4:输入参数。
Step5:点击开始计算。
Step6:运行结果文件生成。
2.App部分程序如下
classdef logisticsApp < matlab.apps.AppBase % Properties that correspond to app components properties (Access = public) UIFigure matlab.ui.Figure logisticsPanel matlab.ui.container.Panel Panel_2 matlab.ui.container.Panel Panel_4 matlab.ui.container.Panel xmEditField matlab.ui.control.NumericEditField xmEditFieldLabel matlab.ui.control.Label rEditField matlab.ui.control.NumericEditField rEditFieldLabel matlab.ui.control.Label x0EditField matlab.ui.control.NumericEditField x0EditFieldLabel matlab.ui.control.Label Label_4 matlab.ui.control.Label UITable_4 matlab.ui.control.Table Label_3 matlab.ui.control.Label UITable_3 matlab.ui.control.Table Label_2 matlab.ui.control.Label UITable_2 matlab.ui.control.Table Label matlab.ui.control.Label UITable matlab.ui.control.Table UIAxes_3 matlab.ui.control.UIAxes UIAxes_2 matlab.ui.control.UIAxes UIAxes matlab.ui.control.UIAxes Panel_3 matlab.ui.container.Panel Button_3 matlab.ui.control.Button Button_2 matlab.ui.control.Button Button matlab.ui.control.Button Panel matlab.ui.container.Panel Button_4 matlab.ui.control.Button yEditField matlab.ui.control.EditField yEditFieldLabel matlab.ui.control.Label xEditField matlab.ui.control.EditField xEditFieldLabel matlab.ui.control.Label EditField_3 matlab.ui.control.NumericEditField Label_7 matlab.ui.control.Label EditField_2 matlab.ui.control.NumericEditField Label_6 matlab.ui.control.Label EditField matlab.ui.control.NumericEditField Label_5 matlab.ui.control.Label end % Callbacks that handle component events methods (Access = private) % Button pushed function: Button_4 function Button_4Pushed(app, event) global data %定义全局变量 [filename,pathname,filterindex]=uigetfile({'.xls';'.xlsx';'.txt';'.'},'打开数据'); if ~filename return; end str1=[pathname,filename]; if (filename==0 & pathname==0) msgbox('您没有选择文件,请重新选择!','打开文件出错','error'); else data=xlsread (strcat([pathname filename])); msgbox('打开及读取数据完毕!','确认','warn'); end end
本文内容来源于网络,仅供参考学习,如内容、图片有任何版权问题,请联系处理,24小时内删除。
作 者 | 郭志龙
编 辑 | 郭志龙校 对 | 郭志龙