User`s guide

6 Programming Overview
6-66
total = 0;
count = 0;
parfor ii = 1:N
% Get partition ii of the datastore.
subds = partition(ds,N,ii);
[localTotal,localCount] = sumAndCountArrivalDelay(subds);
total = total + localTotal;
count = count + localCount;
end
end
Now the MATLAB code calls this new function, so that the counting and summing of the
non-NAN values can occur in parallel loop iterations.
p = parpool('local',4);
reset(ds);
tic
[total,count] = parforSumAndCountArrivalDelay(ds)
parfortime = toc
mean = total/count
Starting parallel pool (parpool) using the 'local' profile ... connected to 4 workers.
Analyzing and transferring files to the workers ...done.
total =
17211680
count =
2417320
parfortime =
13.6401
mean =
7.1201