The following gives a bare-bones outline of how to call parfor. Adjust N and the number of processors (matlabpool open X) to match your machine and see what kind of speed up you get.
clear all;
N = 1000;
A = rand(1000);
B = zeros(size(A));
tic
for i = 1:N
B = A.^10;
end
toc
clear all;
N = 1000;
A = rand(1000);
B = zeros(size(A));
matlabpool open 4;
tic
parfor (i = 1:N)
B = A.^10;
end
toc
matlabpool close;
Return to MATLAB PCT notes
Return to Art Gleason Home
Last Updated: Jan 2008