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 parsim or batchsim function, 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 function runs simulations in serial if a Parallel Computing Toolbox license is not available.

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 configuration in SimulationIntput object to model
setBlockParameterSet block parameter values for simulation using SimulationInput or Simulation object
setModelParameterSet model parameter values for simulation using SimulationInput or Simulation object
setInitialStateSpecify initial state for simulation using SimulationInput or Simulation object
setExternalInputSpecify external input data for top-level input ports using SimulationInput or Simulation 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)
validateValidate contents of SimulationInput object
setPreSimFcnSpecify MATLAB function to run before start of each simulation on Simulink.SimulationInput object
setPostSimFcn Set MATLAB function to run after each simulation
loadVariablesFromMATFileLoad variables from MAT file into Simulink.SimulationInput object
loadVariablesFromExternalSourceLoad variables from a custom file into Simulink.SimulationInput object (Since R2022b)
getSimulationJobsGet all Simulink.Simulation.Job objects from cluster
showContentsView summary of specification in SimulationInput or Simulation object (Since R2020a)

Objects

Simulink.SimulationInputCreate Simulink.SimulationInput objects to make changes to model for multiple or individual simulations
Simulink.Simulation.VariableVariables in Simulink.SimulationInput objects (Since R2020a)
Simulink.Simulation.BlockParameterBlock parameters in Simulink.SimulationInput objects (Since R2020a)
Simulink.Simulation.Future Create Future object for simulation
Simulink.Simulation.Job Simulink.Simulation.Job object for batch simulations
simulink.multisim.DesignStudyCreate design study for multiple simulations (Since R2024a)
simulink.multisim.ExternalInputSpecify a range of external inputs (Since R2024a)
simulink.multisim.VariableSpecify a range of values for model variables (Since R2024a)
simulink.multisim.ModelParameterSpecify a range of values for model parameters (Since R2024a)
simulink.multisim.BlockParameterSpecify a range of block parameters (Since R2024a)

Tools

Multiple SimulationsRun multiple simulations from the Simulink Editor (Since R2021b)
Simulation ManagerMonitor multiple simulations and visualize the simulation data

Topics

Featured Examples