Documentation

Programmatic Simulation

Run simulation from MATLAB® command line, run multiple simulations using different model parameters or input data, sweep parameters across a range of values

Entering simulation commands in the MATLAB Command Window or from a MATLAB file enables you to run unattended simulations. You can also perform Monte Carlo analysis by changing the parameters randomly and executing simulations in a loop. 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.

Functions

sim Simulate dynamic system
model Execute particular phase of simulation of model
find Access and display values of simulation results
get Access and display values of simulation results
who List names of top-level data logging objects in Simulink ModelDataLogs data log
set_param Set system and block parameter values
get_param Get parameter names and values
getInitialState Return initial state structure 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_listener Register listener for block method execution event

Classes

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

Topics

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.

Run Parallel Simulations

Programmatically run model simulations in parallel.

Was this topic helpful?