Q:

Sum of n-1 columns of a double matrix in MATLAB

I have a 1*3000 double matrix.  I am doing some calculation and I need to calculate sum of n-1 columns in each step. 
For example, if I have this matrix:
A = [1 2 3 4 5 6]

The summation I'm looking for should be like this:
B = [0 1 1+2 1+2+3 1+2+3+4 1+2+3+4+5] = [0 1 3 6 10 15]

Meaning, in each step, we calculate the sum of n-1 columns of the matrix while n starts from 1 to the number of columns of the matrix. 
Since the number of columns is 3000, I cannot use 'for' loop. 
Could you please tell me what should I do? 

A:

You can do that by using the function cumsum:
A = [1 2 3 4 5 6];
C = cumsum(A);
out = [0 C(1:end-1)]

now out is: [0  1  3  6  10  15]

