This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Wait for Simulink.Simulation.Future objects to complete simulation


Ok = wait(Future)



Ok = wait(Future) blocks the command prompt until each element of the Simulink.Simulation.Future array, Future is in a 'finished' state.


collapse all

This example shows how to use the wait method on an array of future objects.

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 to 'RunInBackground' to enable the use of command prompt while the simulations are running and to create an array of Simulink.Simulation.Future objects.

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

Use the wait method on Future to block the execution.

Ok = wait(Future)

Input Arguments

collapse all

Array of Simulation.Simulink.Future objects. To create Future, run parsim with 'RunInBackground' option set to 'on'.

Example: Future = parsim(in,'RunInBackground','on')

Output Arguments

collapse all

Ok is true if the wait completes successfully, false if any of the Future objects failed execution or were canceled. Specified as 1 if true, 0 if false.

Introduced in R2017b