Project

General

Profile

%% Batch processing of a function
% Copyright 2015 The MathWorks, Inc.

%% Close any open pool of workers

% Delete the current pool and don't open if there isn't one.
delete(gcp('nocreate'));


%% Submit job.

% change profile from 'local' and adjust pool size if a cluster is available
job1=batch('paramSweepSerial',4,{10,10});

% job1=batch('paramSweepParallel',4,{10,10},'Pool',1);


%% Check status
% We can check the status of the job by querying its state

job1.State

%% Wait for completion
% If depending on outputs to proceed, force command prompt to wait

wait(job1); % optional


%% Plot data when job is finished

% Retrieve outputs from the function we called.
jobOut=fetchOutputs(job1);

% View it
visualizeParamSweep(jobOut);
computationTime=jobOut{4};
fprintf('\nComputation time: %fs\n',computationTime);

(2-2/12)