%% Cumulative Sum of Vector
% Find the cumulative sum of the integers from 1 to 5. The element B(2) is the sum of A(1) and A(2), while B(5) is the sum of elements A(1) through A(5).

A = 1:5;
B = cumsum(A)

% Copyright 2012 The MathWorks, Inc.