Main Content

取消

Cancel a pending, queued, or runningSimulink.Simulation.Futureobject

Description

example

取消(Future)stops the objects of theSimulink.Simulation.Futurearray,Future, that are currently in'pending','queued', or'running'state. For elements of theFuturesin the'finished'state, no action is taken.

Examples

collapse all

This example shows how to use the取消method on an array offutureobjects to stop the simulations.

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

Open the model and define a vector of Mu values.

open_system('vdp'); Mu_Values = [0.5:0.25:1000]; MuVal_length = length(Mu_Values)

UsingMu_Values, initialize an array ofSimulink.SimulationInputobjects. To preallocate the array, a loop index is made to start from the largest value.

fori = MuVal_length:-1:1 in(i) = Simulink.SimulationInput('vdp'); in(i) = in(i).setBlockParameter('vdp/Mu',...“获得”,num2str(Mu_Values(i)));end

Simulate the model usingparsim. Set to 'RunInBackground' to enable the use the command prompt, while simulations are running.

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

Now, assume that you want to run simulations with different values of Mu and cancel the ongoing simulations.

取消(Future)

Input Arguments

collapse all

Array ofSimulation.Simulink.Futureobjects. To createFuture, runparsimwith'RunInBackground'option set to'on'.

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

See Also

Functions

Classes

Introduced in R2018a