User`s guide
Looping Over a Distributed Range (for-drange)
5-23
To loop over all elements in the array, you can use for-drange on the dimension of
distribution, and regular for-loops on all other dimensions. The following example
executes in an spmd statement running on a parallel pool of 4 workers:
spmd
PP = zeros(6,8,12,'codistributed');
RR = rand(6,8,12,codistributor())
% Default distribution:
% by third dimension, evenly across 4 workers.
for ii = 1:6
for jj = 1:8
for kk = drange(1:12)
PP(ii,jj,kk) = RR(ii,jj,kk) + labindex;
end
end
end
end
To view the contents of the array, type:
PP