Main Content


Generate MATLAB App to simulate model and deploy application

Since R2020b



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

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

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


collapse all

Generate a MATLAB app using the simulink.compiler.genapp function for the model, sldemo_suspn_3dof.

Open the model.


Generate a MATLAB app named suspn_3dof_app for the model.

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

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

You can use the simulink.compiler.genapp function also allows you to generate an app with the SimAppTemplate or the SLSimApp2 template. To generate an app using one of the built-in templates, use the template name and 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 a string.

Template to use to generate a MATLAB app, specified as MultiPaneSimApp, SimAppTemplate, or SLSimApp2.

Directory for creating build artifacts, specified as a string.

Maximum number of data points to log to the MATLAB workspace, specified as a double.

Maximum number of data points for scopes to log to the MATLAB workspace, specified as a double.

Option to incorporate a web view of the model in the generated app, specified as 'off' or 'on'. The 'UseSimulinkWebView' option requires a Simulink Report Generator™ license.

Names of MAT files that specify inputs for the Simulink.SimulationInput objects, specified as strings.

Version History

Introduced in R2020b