Skip to Main Content Skip to Search
Product Documentation

Plotting Distributed Data Using pmode

Because the labs 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:

  1. Use the gather function to collect the entire array into the workspace of one lab.

  2. Transfer the whole array from any lab to the MATLAB client with pmode lab2client.

  3. Plot the data from the client workspace.

The following example illustrates this technique.

Create a 1-by-100 codistributed array of 0s. With four labs, each lab 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 lab 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 lab 1.

P>> P = gather(D, 1);

Transfer the array from the workspace of lab 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 parallel jobs, is to plot the data to a file, then view it from a later MATLAB session.

  


Free Parallel Computing Interactive Kit

See how to solve large problems with minimal effort and reduce simulation time.

Get free kit

Trials Available

Try the latest versions of parallel computing products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS