a = 1:1:10;
% you could do it with a loop
s = zeros(1,numel(a));
s(1) = a(1);
for i = 2:numel(a)
s(i) = s(i-1) + a(i);
end
s
% or you could just do
s = cumsum(a)
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!