Run Multiple Simulations

Provide a collection of inputs to a model and run multiple simulations with these inputs using the parsim or the batchsim function

For workflows that involve multiple parallel simulations and logging of large data, you can create simulation sets using an array of Simulink.SimulationInput objects. SimulationInput objects help you run multiple simulation variants without changing your model. Arrays of SimulationInput objects enable you to run multiple simulations.

With a Parallel Computing Toolbox™ license, you can use the parsim function to run the simulations in parallel. The function distributes multiple simulations to parallel workers to speed up overall simulation time. parsim with Parallel Computing Toolbox also automates the creation of parallel pools, identifies file dependencies, and manages build artifacts for Accelerator and Rapid Accelerator simulations. The parsim command run multiple simulations in serial if Parallel Computing Toolbox license is not available.

In addition, you can use batchsim with Parallel Computing Toolbox and MATLAB® Parallel Server™ licenses. When you use batchsim, simulations are offloaded onto a compute cluster. You can open a separate MATLAB session to access the job and the results.

To get started, see Run Multiple Simulations and Run Parallel Simulations Using parsim.

Functions

batchsimOffload simulations to run on a compute cluster
parsimSimulate dynamic system multiple times in parallel or serial
applyToModelApply changes to the model specified through a SimulationInput object, in
setBlockParameterSet block parameters to be used for a specific simulation through SimulationInput object, in
setModelParameterSet model parameters to be used for a specific simulation through SimulationInput object, in
setInitialStateSet initial state to be used for a specific simulation through SimulationInput object, in
setExternalInputSet external inputs for a simulation through SimulationInput object, in
setVariableSet variables for a simulation through SimulationInput object, in
validateValidate the contents of the SimulationInput object, in
setPreSimFcnSpecify a MATLAB function to run before start of each simulation through SimulationInput object, in
setPostSimFcn Specify a MATLAB function to run after each simulation is complete through SimulationInput object, in
loadVariablesFromMATFileLoad variables from MAT-file into a Simulink.SimulationInput object, in
getSimulationJobsGet all Simulink.Simulation.Job objects from cluster
contentsView the contents of the Simulink.SimulationInput object

Classes

Simulink.SimulationInputCreates SimulationInput objects to make changes to a model for multiple or individual simulations
Simulink.Simulation.VariableVariables in Simulink.SimulationInput objects
Simulink.Simulation.BlockParameterBlock parameters in Simulink.SimulationInput objects
Simulink.Simulation.Future Create Future object for simulation
Simulink.Simulation.Job Execute batchsim to create a Simulink.Simulation.Job object, simJob

Tools

Simulation ManagerMonitor multiple simulations and visualize the simulation data

Topics

Run Multiple Simulations

Directly run multiple simulations from the parsim and batchsim commands.

Run Parallel Simulations Using parsim

Example of multiple parallel simulations workflows.

Run Parallel Simulations

Programmatically run model simulations in parallel.

Multiple Simulation Workflows

Understand the similarities and differences between parsim, parsim with RunInBackground, and batchsim.

Analyze Results Using Simulation Manager

Use the Simulation Manager to visualize the simulation data, analyze the simulation results and the simulation trends.

Featured Examples