User`s guide
Apply Callbacks to MJS Jobs and Tasks
6-27
Create and save a callback function clientTaskCompleted.m on the path of the
MATLAB client, with the following content. (If you created this function for the previous
example, you can use that.)
function clientTaskCompleted(task,eventdata)
disp(['Finished task: ' num2str(task.ID)])
Create objects for the cluster, job, and task. Then submit the job. All the callback
properties are set from the profile when the objects are created.
c = parcluster('MyMJS');
j = createJob(c,'Name','Job_52a');
createTask(j,@rand,1,{2,4});
submit(j)
Job_52a now queued
Job_52a now running
Finished task: 1
Job_52a now finished
Tips
• You should avoid running code in your callback functions that might cause conflicts.
For example, if every task in a job has a callback that plots its results, there is no