diary

Display or save Command Window text of Simulink.Simulation.Job object

Description

example

diary(simJob) displays the Command Window output from the Simulink.Simulation.Job object, simJob, in the MATLAB® Command Window. The Command Window output is captured only if the batchsim command includes the 'CaptureDiary' argument with a value of true.

diary(simJob,'filename') causes the Command Window output from the batch job to be appended to the specified file. Open the file, filename, with any text editor.

Examples

collapse all

This example uses sldemo_househeat model to show how to display the diary of the Simulink.Simulation.Job object, simJob. To create a simJob, you run parallel simulations using the batchsim command.

1. Open the model.

open_system('sldemo_househeat');

2. Define a set of values for different temperatures.

setPointValues = 65:2:85;
spv_Length = length(setPointValues);

3. Using setPointValues, initialize an array of Simulink.SimulationInput objects.

in(1:spv_Length) = Simulink.SimulationInput('sldemo_househeat');
for i = 1:1:spv_Length 
    in(i) = in(i).setBlockParameter('sldemo_househeat/Set Point',...
        'Value',num2str(setPointValues(i)));
end

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.

simJob = batchsim(in,'Pool',3)
                  ID: 1
                Type: pool
          NumWorkers: 4
            Username: #####
               State: running
      SubmitDateTime: ##-###-#### ##:##:##
       StartDateTime: 
    Running Duration: 0 days 0h 0m 0s

5. Use the diary method of the Simulink.Simulation.Job object to display the output of the batch job in the MATLAB command window.

Note that the diary is not displayed here because this is an example model.

diary(simJob)

Input Arguments

collapse all

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

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

Specify a file to append with Command Window output text from the Simulink.Simulation.Job object.

Example: diary(simJob,'abc.txt')

Introduced in R2018b