Main Content

simulink.compiler.genapp

Generate MATLAB App to simulate model and deploy application

Description

example

simulink.compiler.genapp('modelName') analyzes a Simulink model and generates a deployable MATLAB® app, to simulate the model in rapid accelerator simulation mode with different inputs, parameters, and initial states and plot the results.

simulink.compiler.genapp(modelName,Name,Value) generates a deployable MATLAB app with the specified options.

While generating an app, ensure that the current working folder does not contain older generated app artifacts.

Examples

collapse all

This example shows how to generate a MATLAB app using the simulink.compiler.genapp function for the model, sldemo_suspn_3dof.

Open the model

open_system('sldemo_suspn_3dof')

Generate a MATLAB app for the model with app name, suspn_3dof_app.

simulink.compiler.genapp('sldemo_suspn_3dof', 'AppName', 'suspn_3dof_app')

Once the app is generated, click Simulate to view the simulation result of the model

The simulink.compiler.genapp function also allows you to generate an app with the SimAppTemplate and the SLSimApp2 template. To generate an app using this template, use the name-value pair along with the model name as arguments in the simulink.compiler.genapp function.

Before generating the app, clear the generated artifacts from the Current Folder and the workspace.

myApp = simulink.compiler.genapp('sldemo_suspn_3dof', 'Template', 'SLSimApp2')

Input Arguments

collapse all

Name of model for which the MATLAB app is generated, specified as a string.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'AppName', 'modelNameApp'

Name of the generated app, specified as the comma-separated pair consisting of 'AppName' and a string.

Template to use to generate a MATLAB app. Specified as the comma-separated pair consisting of 'Template' and a string.

Directory for creating build artifacts, as the comma-separated pair consisting of 'OutputDir' and a string.

MAT files that specify inputs for the Simulink.SimulationInput objects, specified as the comma-separated pair consisting of 'InputMatFiles' and a MAT file.

Version History

Introduced in R2020b