This example shows how to run parallel simulations in batch and fetch
the resulting Simulink.SimulationOutput
objects from the
Simulink.Simulation.Job
object. batchsim
command
offloads simulations to the compute cluster, enabling you to carry out other tasks while
the batch job is processing, or close the client MATLAB® and access the batch job later.
1. Open the
model.
2. Define a set of values for different temperatures.
3. Using setPointValues
, initialize an array of
Simulink.SimulationInput
objects.
4. 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 job object returns useful metadata as shown. You can use the job
ID
to access the job object later from any machine.
NumWorkers
displays how many workers are running the simulations –
the number of workers specified in the 'Pool'
argument plus an
additional head
worker.
ID: 1
Type: pool
NumWorkers: 4
Username: #####
State: running
SubmitDateTime: ##-###-#### ##:##:##
StartDateTime:
Running Duration: 0 days 0h 0m 0s
5. Access the results of the batch job using the fetchOutputs
method. fetchOutputs
returns an array of
Simulink.SimulationOuput
objects. You can fetch outputs only once
simJob
is in finished
state.
1x11 Simulink.SimulationOutput array