Main Content


Generate MATLAB App to simulate model and deploy application



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.


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


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 SLSimApp2 template. The SLSimApp2 template uses pop-up windows for editing reference variables and selecting signals to plot. 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 comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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.Simulation.Input objects, specified as the comma-separated pair consisting of 'InputMatFiles' and a MAT file.

Introduced in R2020b