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.

cancel

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

Syntax

cancel(simJob)
cancel(simJob,'Message')

Description

example

cancel(simJob) stops the Simulink.Simulation.Job object, simJob, that is currently in 'pending', 'queued', or 'running' state.

cancel(simJob,'Message') stops the Simulink.Simulation.Job object, simJob, that is in 'pending', 'queued', or 'running' state and displays a user-specified message.

The State property of Simulink.Simulation.Job 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 again.

Note

On canceling the job, the results of the completed simulations in the job are also lost.

Examples

collapse all

This example shows how to use the cancel method on a 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);

2. Using mu_Values, initialize an array of Simulink.SimulationInput objects.

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.

cancel(simJob)

Input Arguments

collapse all

A Simulink.Simulation.Job object. To create a simJob, run batchsim.

Example: simJob = batchsim(in,'Pool',6)

Introduced in R2018b