Create and Deploy a Script with万博1manbetx编译器

在此示例中,您准备了一个模型以与万博1manbetx®编译器™,开发和编译脚本,然后将其部署为独立应用程序。

准备模型

万博1manbetxSimulink编译器使用快速加速器仿真目标来生成可执行的可执行文件以提交Simulink模型。万博1manbetx万博1manbetxSimulink编译器仅支持可以万博1manbetx在快速加速器模式下运行的模型。要将模型的仿真模式设置为快速加速器,请使用模型参数'simulationmode'仿真input目的。To enable simulation deployment of the model, your model must be supported by the Rapid Accelerator mode correctly.

万博1manbetxSimulink编译器只支持万博1manbetxSIM功能语法万博1manbetxSimulink.SimulationInput对象并返回万博1manbetxsimulink.simulationOutput目的。

如果模型中存在回调,则在应用程序的构建时间中调用它们。但是,一旦部署了应用程序或脚本,这些回调就不会调用。

写脚本以部署

准备模型后,编写要部署的脚本。在此示例中,我们使用模型并更改脚本中的可调参数之一。

在matlab中®艾德itor, create a functiondeployedScript。在此功能中,创建一个万博1manbetxSimulink.SimulationInput模型的对象sldemo_suspn_3dof并改变价值MBsetVaria方法的方法万博1manbetxSimulink.SimulationInput目的。为确保模型以快速加速器模式运行,请设置仿真模式迅速的through thesetModelParameter方法的方法万博1manbetxSimulink.SimulationInput对象或使用万博1manbetxsimulink.compiler.configurefordeployment功能如下所示。

模拟中修改的变量可以在基本工作区或顶部模型工作区中。

功能deployedscript()in = s万博1manbetximulink.simulationInput('sldemo_suspn_3dof');in = in.setVariable('MB',1000);in = 万博1manbetxsimulink.simulatio.configurefordeployment(in);out = sim(in);结尾

将功能保存为一个deployedScript.m

Compile Script for Deployment

Before compiling the script that you want to deploy, ensure that the files for the model and script, in this casesldemo_suspn_3dofdeployedScript.m,包含在MATLAB搜索路径上。要编译脚本,请使用MCCcommand with the script name. To learn more about theMCC命令,请参阅MCC

MCC-m deployedScript.m

故障排除提示

万博1manbetxSimulink编译器自动将依赖项和部署脚本中的依赖项打包。如果命令MCC找不到依赖性,您可能会看到错误。

  • 如果您看到错误“无法解析名称万博1manbetxSimulink.SimulationInput”,检查模型是否在路径上。

  • 如果因文件位于另一个目录中,请使用标志将其连接-a。例如,MCC -M scriptName.m -a mydatafile.dat

运行已部署的脚本

安装MATLAB运行

要运行已部署的可执行文件,您需要适当的运行时环境。安装MATLAB运行时, 看//www.tianjin-qmedu.com/s manbetx 845products/compiler/matlab-runtime.html

运行已部署的应用程序

您只能在开发部署应用程序的平台上运行已部署的应用程序。

从Windows命令提示符运行已部署的应用程序。从命令提示符中运行已部署的应用程序使应用程序可以在遇到错误时在命令提示符中打印诊断消息。这些消息可以是解决问题的有用工具。

也可以看看

||||

Related Topics