% single CPU/core: vectorized code
N = 1024;
i = 1:N;
a = sin(i.*2.*pi/N);
plot(a);

% using for-loop - not the way to go (just to simulate some work!)
a = zeros(1, N);
for i = 1:N
    a(i) = sin(i*2*pi/N);
end
plot(a);

% parallel for
% create a pool of workers (12) (local profile by default):
matlabpool open 12;    
a = zeros(1, N);
parfor i=1:N
    a(i) = sin(i*2*pi/N);
end
matlabpool close;      % close the pool of workers
plot(a);  % i has undefined state after the loop!

