This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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.


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 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_listener Register listener for block method execution event


Simulink.SimState.ModelSimState Access SimState snapshot data
eventData Provide 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?