Main Content

Run Multiple Simulations

Provide collection of inputs to model and run multiple simulations with these inputs using the parsim function, the batchsim function, or the Multiple Simulations panel in Simulink®

For workflows that involve multiple parallel simulations and logging of large data, you can use the command line API for parsim or batchsim commands, or run the simulations with the Multiple Simulations panel in the Simulink Editor.

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. Using the parsim function with Parallel Computing Toolbox allows you to automate 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 the batchsim function with Parallel Computing Toolbox and MATLAB® Parallel Server™ licenses. When you use the batchsim function, 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 Running Multiple Simulations and Run Parallel Simulations for a Thermal Model of a House 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
setInitialStateConfigure Simulink.SimulationInput object to set initial state for simulation
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

Multiple SimulationsRun multiple simulations from the Simulink Editor
Simulation ManagerMonitor multiple simulations and visualize the simulation data

Topics