Cancel a pending, queued, or running
cancel( stops the
simJob, that is
'running' state and displays a user-specified message.
State property of
object is set to finished, and other pending simulations are canceled. Canceling a job
object disables you to fetch results from it. A canceled job object cannot be started
On canceling the job, the results of the completed simulations in the job are also lost.
This example shows how to use the
cancel method on
simJob object to stop simulations. The example runs several
simulations of the
vdp model, varying the value of the gain Mu.
1. 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);
mu_Values, initialize an array of
in(1:muVal_Length) = Simulink.SimulationInput('vdp'); for i = 1:1:muVal_Length in(i) = in(i).setBlockParameter('vdp/Mu',... 'Gain',num2str(mu_Values(i))); end
3. Specify the pool size of the number of workers to use. In addition to the number of workers used to run simulations in parallel, a head worker is required. In this case, assume that three workers are available to run a batch job for the parallel simulations. The simulations are offloaded onto the default cluster profile.
simJob = batchsim(in,'Pool',3);
4. Now, assume that you want to run simulations with different values of Mu and cancel the ongoing simulations.
Simulink.Simulation.Job object. To create a
simJob = batchsim(in,'Pool',6)