% parfor loop and data dependence.
% nonindexed variable outside the loop.

parpool(4);   % 4 workers on a Mike-II node.

tic;

nsize = 20;

a = zeros(1,nsize);
ktmp = 0;

parfor k=1:nsize
   ktmp = k+k+k;
   a(k) = ktmp;  
end

toc;

a
ktmp

delete(gcp);

