Main Content

Simulink.Simulation.Future Class

Namespace: Simulink.Simulation

Create Future object for simulation


Create a Simulink.Simulation.Future object when you execute parsim with the 'RunInBackground' argument set to 'on'. The parsim command runs multiple simulations in parallel using the inputs specified with an array of Simulink.SimulationInput objects. You can use this object to monitor the status of ongoing simulations, fetch outputs of completed simulations, or cancel ongoing simulations.

The parsim command uses the Parallel Computing Toolbox™ license to run the simulations in parallel. parsim runs the simulations in serial if a parallel pool cannot be created or if Parallel Computing Toolbox is not used.


future = parsim(in,'RunInBackground','on') creates a Simulink.Simulation.Future object, future, while running multiple simulations in parallel using the inputs specified in the Simulink.SimulationInput object, in.

Input Arguments

expand all

A Simulink.SimulationInput object or an array of Simulink.SimulationInput objects is used to run multiple simulations. Specify parameters and values of a model to run multiple simulations without making it dirty.

Example: in = Simulink.SimulationInput('vdp'), in(1:10) = Simulink.SimulationInput('vdp')

Set to 'on', to run simulations asynchronously, keeping the MATLAB® command prompt available.


expand all

Text log of outputs from the simulation.

This property is read-only.

ID of the future object, specified as a scalar integer.

This property is read-only.

Whether a call to fetchNext or fetchOutputs has read the outputs in the Simulink.Simulation.Future object array, specified as 1 if true and 0 if false.

This property is read-only.

Current state of future object array, specified as 'pending', 'queued', 'running', 'finished','failed', or 'unavailable'.

This property is read-only.





Cancel a pending, queued, or running Simulink.Simulation.Future object


Fetch next available unread output from Simulink.Simulation.Future object array


Retrieve Simulink.SimulationOutput from Simulink.Simulation.Future


Wait for Simulink.Simulation.Future objects to complete simulation


collapse all

This example shows how to create a Simulink.Simulation.Future object array and use it to retrieve outputs and see the status of simulations.

This example runs several simulations of the vdp model, varying the value of the gain Mu.

Open the model and define a vector of Mu values.

Mu_Values = [0.5:0.25:5];
MuVal_length = length(Mu_Values);

Using Mu_Values, initialize an array of Simulink.SimulationInput objects. To preallocate the array, a loop index is made to start from the largest value.

for i = MuVal_length:-1:1
    in(i) = Simulink.SimulationInput('vdp');
    in(i) = in(i).setBlockParameter('vdp/Mu',...

Simulate the model using parsim. Set it to 'RunInBackground', to be able to use the command prompt, while simulations are running.

Future = parsim(in,'RunInBackground','on');

Use the fetchNext method on Future simulations.

for i = 1:MuVal_length
    [completedIdx,simOut] = fetchNext(Future)

Version History

Introduced in R2018a

See Also