User`s guide

8 Program Communicating Jobs
8-6
When your cluster object is defined, you create the job object with the
createCommunicatingJob function. The job Type property must be set as 'SPMD'
when you create the job.
cjob = createCommunicatingJob(c,'Type','SPMD');
The function file colsum.m (created in “Code the Task Function” on page 8-4) is on
the MATLAB client path, but it has to be made available to the workers. One way to do
this is with the job’s AttachedFiles property, which can be set in the profile you used,
or by:
cjob.AttachedFiles = {'colsum.m'}
Here you might also set other properties on the job, for example, setting the number of
workers to use. Again, profiles might be useful in your particular situation, especially
if most of your jobs require many of the same property settings. To run this example on
four workers, you can established this in the profile, or by the following client code:
cjob.NumWorkersRange = 4
You create the job’s one task with the usual createTask function. In this example, the
task returns only one argument from each worker, and there are no input arguments to
the colsum function.
t = createTask(cjob, @colsum, 1, {})
Use submit to run the job.
submit(cjob)
Make the MATLAB client wait for the job to finish before collecting the results. The
results consist of one value from each worker. The gplus function in the task shares
data between the workers, so that each worker has the same result.
wait(cjob)
results = fetchOutputs(cjob)
results =
[136]
[136]
[136]
[136]