Click on Popup Symbol

This is a demo of a click on pop-up window offering extra help on a topic.





Behavior of Codistributed Arrays

When matlabpool is used, Codistributed arrays (on workers) are seen as composite arrays on the client. These arrays can not be accessed from the client. To make them accessible on the client, you will need to use the gather function to either collect from all workers to one or replicate it to all workers. You would encounter errors if gather were not used.


>> spmd
[A, x, b] = linearSystem(M, C, i);
y = A\b;  % solves for y
end
>> y{1}
??? Error using ==> Composite.subsref at 72
. . .

It is illegal to retrieve a portion of a codistributed array


To make y accessible on the client:


>> spmd
y1=gather(y, 1); % collects y to worker 1
end
>> y1{1}
ans =
    2.0000
    2.0000
    2.0000

Note that if you use pmode, gather is not necessary.