Because the workers running a job in pmode are MATLAB® sessions without displays, they cannot create plots or other graphic outputs on your desktop.
When working in pmode with codistributed arrays, one way to plot a codistributed array is to follow these basic steps:
Use the gather function to collect the entire array into the workspace of one worker.
Transfer the whole array from any worker to the MATLAB client with pmode lab2client.
Plot the data from the client workspace.
The following example illustrates this technique.
Create a 1-by-100 codistributed array of 0s. With four workers, each has a 1-by-25 segment of the whole array.
P>> D = zeros(1,100,codistributor1d()) Lab 1: This lab stores D(1:25). Lab 2: This lab stores D(26:50). Lab 3: This lab stores D(51:75). Lab 4: This lab stores D(76:100).
Use a for-loop over the distributed range to populate the array so that it contains a sine wave. Each worker does one-fourth of the array.
P>> for i = drange(1:100) D(i) = sin(i*2*pi/100); end;
Gather the array so that the whole array is contained in the workspace of worker 1.
P>> P = gather(D, 1);
Transfer the array from the workspace of worker 1 to the MATLAB client workspace, then plot the array from the client. Note that both commands are entered in the MATLAB (client) Command Window.
pmode lab2client P 1 plot(P)
This is not the only way to plot codistributed data. One alternative method, especially useful when running noninteractive communicating jobs, is to plot the data to a file, then view it from a later MATLAB session.