Main Content

Run Individual Simulations

Run and control individual simulations directly from the Simulink® Editor or programmatically from the MATLAB® command prompt

Simulating a model gives you results of the algorithms that you build through the process of modeling. You can interact with the simulations by pacing the simulation, tuning model parameters, stopping or pausing the simulation, and displaying port values to evaluate the design of your model. Simulations help you understand the design and behavior of your model.

Simulate a model interactively by clicking the Run button in the Simulink Toolstrip, or programmatically using functions like sim and set_param in the MATLAB Command Window or a MATLAB script.

For information about running parallel and batch simulations, see Run Multiple Simulations.

Model Settings

expand all

InputOption to load external input data for simulation using top-level input ports
Initial stateOption to specify initial model state or operating point for simulation
Final statesOption to log final state values
Save final operating pointOption to save complete model operating point when simulation is paused or stopped
Operating point object from a different releaseDiagnostic behavior when loading initial operating point generated in different release
Operating point restore interface checksum mismatchDiagnostic behavior when interface checksum does not match between initial operating point and model

Tools

Simulation Pacing OptionsSlow simulation to a specified ratio of simulation time to wall clock time

Functions

expand all

simRun and script programmatic simulations of Simulink models
set_paramSet Simulink parameter value
get_paramGet parameter names and values
slsim.allowedModelChangesDetermine changes you can make to model based on simulation status (Since R2022b)
initializeInitialize simulation represented by Simulation object (Since R2024a)
pausePause active simulation represented by Simulation object (Since R2024a)
resumeContinue paused simulation represented by Simulation object (Since R2024a)
setBlockParameterSet block parameter values for simulation using SimulationInput or Simulation object
setModelParameterSet model parameter values for simulation using SimulationInput or Simulation object
setExternalInputSpecify external input data for top-level input ports using SimulationInput or Simulation object
setInitialStateSpecify initial state for simulation using SimulationInput or Simulation object
setPostSimFcn Set MATLAB function to run after each simulation
setPreSimFcnSpecify MATLAB function to run before start of each simulation on Simulink.SimulationInput object
setVariableSet variable values for simulation using SimulationInput or Simulation object
setVariantConfigurationSet variant configuration for simulation using SimulationInput object (Since R2024a)
getVariantConfigurationGet name of variant configuration from SimulationInput object (Since R2024a)
startStart simulation represented by Simulation object (Since R2024a)
stepAdvance simulation represented by Simulation object by specified amount (Since R2024a)
stopStop simulation represented by Simulation object (Since R2024a)
terminateTerminate simulation represented by Simulation object (Since R2024a)
Simulink.BlockDiagram.getInitialStateGet initial state data from block diagram
get Get operating point information for Stateflow chart, MATLAB System block, or S-function
setSet operating point information for Stateflow chart, MATLAB System block, or S-function
findQuery and access properties on Simulink.SimulationOutput object
getAccess simulation results in Simulink.SimulationOutput object
getSimulationMetadataAccess simulation metadata in Simulink.SimulationOutput object
removePropertyRemove property from Simulink.SimulationOutput object
setUserDataAdd data to metadata in Simulink.SimulationOutput object
setUserStringAdd string to metadata in Simulink.SimulationOutput object
whoGet names of editable properties on Simulink.SimulationOutput object

Objects

expand all

SimulationControl simulation execution and tune variable, block parameter, and model parameter values (Since R2024a)
Simulink.SimulationInputCreate Simulink.SimulationInput objects to make changes to model for multiple or individual simulations
Simulink.op.ModelOperatingPointComplete information that represents model operating point in simulation
Simulink.SimulationOutputAccess simulation outputs and metadata
Simulink.SimulationMetadataAccess metadata of simulation runs

Topics

Run Basic Simulations

Analyze Simulations

Perform Iterative Simulations With Fast Restart