Run Individual Simulations Programmatically

Programmatically run and control individual simulations from the MATLAB® command prompt. Enable timeouts, capture errors, and access simulation metadata.

Entering simulation commands in the MATLAB Command Window or from a MATLAB file enables you to run unattended simulations. To run simulations programmatically, you can use either sim or set_param. sim gives you richer options for specifying configuration parameters for your simulation and saving simulation outputs, while set_param enables you to control your simulations as they run.

To get started, see Run Simulations Programmatically and Control Simulations Programmatically.


simSimulate dynamic system
modelExecute particular phase of simulation of model
find Access and display values of simulation results
get Access and display values of simulation results
whoList names of top-level data logging objects in Simulink ModelDataLogs data log
set_paramSet system and block parameter values
get_paramGet parameter names and values
getInitialStateReturn initial state data of block diagram
setBlockSimState Set SimState of individual Stateflow Chart, MATLAB Function, or S-function block
getBlockSimState Access SimState of individual Stateflow Chart, MATLAB Function, or S-function block
add_exec_event_listenerRegister listener for block method execution event


Simulink.SimState.ModelSimState Access SimState snapshot data
eventDataProvide information about block method execution events


Run Simulations Programmatically

Programmatically simulate a model using the sim function.

Control Simulations Programmatically

Programmatically control model simulations with the set_param and get_param functions.

Choosing a Simulation Mode

How to choose between Normal, Accelerator, and Rapid Accelerator modes

Model Parameters

Parameters specific to models.

Access Block Data During Simulation

How to use the Simulink® block run-time interface to access block data during a simulation.

Save and Restore Simulation State as SimState

How to save and restore the complete simulation state for further simulation.

Was this topic helpful?