% vector.m

clearvars;
%maxNumCompThreads(8);

n = 100000000;
a = zeros(n, 1);
b = rand(n - 1, 1);

% (1) for statement
tic
for i = 1 : n - 1
	a(i + 1) = a(i) + b(i);
end
toc
sum(a)

% (2) vector
tic
a(2:n) = a(1:n-1) + b(1:n-1);
toc
sum(a)

% (3) vector (V.2)
tic
i = 1 : n - 1;
a((i) + 1) = a(i) + b(i);
toc
sum(a)
