生成,修改和部署MATLABApp for a金宝app模型
Thesimulink.compiler.genapp
enables you to automatically generate a MATLAB®app for a Simulink®model. You can compile and deploy the automatically generated app using theMCC
command. This example generates an app for a model, compiles and deploys the app, and shows how you can customize the app using the App Designer.
TheMultisimpaneapp
is the default template used for app generation. With this template, the generated app works for and is customizable. This template also allows you to pause a simulation, tune parameters in the middle of a simulation, and configure an app for deployment.
This example shows you how to use thesimulink.compiler.genapp
function to generate a deployable app for the modef14
. You can use the generated app to tune the parameters of the model and run simulations with different parameter values. You can also customize the app in the App Designer and deploy the generated app for use outside of MATLAB.
打开模型
Thesimulink.compiler.example.AppGeneration
命令将示例项目加载到您的路径上。该项目包含此示例所需的所有文件,包括模型。打开模型f14
.
金宝appsimulink.compiler.example.appgeneration;open_system('f14')
Generate a MATLAB App for the Model
Use thesimulink.compiler.genapp
function to generate an app for thef14
model. Running thesimulink.compiler.genapp
function with the model name as an argument generates an app namedf14app
, which is specified as an argument. The default name of the generated app ismodelname_slsimapp
. Simulink Compiler uses a default template to generate the app. You can tune the parameters and simulate the model for which the app is generated. The generated app also provides a plot of the simulation results. All these files are generated into thef14app
目录中。
To generate the app, theSaveFormat
对于输出数据必须是数据集
或者Structure
with time. To changeSaveFormat
为了f14
model, in the造型tab of the Simulink Toolstrip, go to模型Settings. In the数据导入/导出pane, change格式to数据集
.
simulink.compiler.genapp('f14','AppName','f14app');
After generating the app, Clickto simulate the app.
On the right side of the model image, you can tune the parameter values and run simulations with different values.
Use the arrow at the bottom to display the plot for the simulation output. The情节布局控件使您可以添加多个图。默认情况下,该窗格中显示了一个轴。您可以随时使用/删除轴情节布局controls
Use the arrows on the left side of the plots to open theLogged Signalspane. To display the signals in the plots, first select the plot and then check the signals in the signal pane. Repeat this process for all the plots. This functionality allows you to compare results and modify the app as needed.
ClickLoad在应用程序的工具条上加载来自外部文件的参数和输入信号。那个设定Configure For Deployment配置该应用程序,以便可以独立于MATLAB部署和使用。部署选项是独立的桌面应用程序或Web应用程序。
Once the app is generated, three folders are created in the app folder:
AppHelper— Contains almost all the code that is used by the generated app. You can use this folder to navigate through the app, to understand how the app works, and potentially customize it.
资产文件夹— Contains all the assets the app uses, such as images, styles, HTML, JavaScript, model data, and some metadata
apputils— Contains scripts to help you deploy the app as a standalone desktop app or a web app, test the deployed standalone app in MATLAB, and run the generated app directly from MATLAB.
See Also
simulink.compiler.genapp
|simulink.compiler.configureForDeployment
|MCC
|deploytool
|sim