% time02 - Timing example that illustrates parfor
% 
% Good for embarassingly parallel situations such as
% running a parameter sweep

matlabpool open;

% N = 10
N = 1200
M = 12
D = zeros(M,2);
tic
parfor k = 1:M
    A = rand(N);
    B = rand(N);
    C = A*B - B*A;
    D(k,:) = [C(1,N) C(N,1)]
end
toc
fprintf('%12.4e fmults %12.4e fadds\n',M*(2*N^3),M*(2*N^3+N^2))
D

matlabpool close;
