Q:

partial cumulative sums on a [n-by-m] matrix in MATLAB

I'm looking for a solution for the following problem:
I have a matrix, for example
A = [1 2 3;
     4 5 6;
     7 8 9;
     1 2 3;]

I need the partial cumulative sums like this:
B = 1  2  3    % 1+0      2+0      3+0
C = 8  10 12   % 1+7      2+8      3+9
D = 12 15 18   % 1+7+4    2+8+5    3+9+6
E = 13 17 21   % 1+7+4+1  2+8+5+2  3+9+6+3

Help please!

A:

You can have cumulative sums (or as you call them partial sums) with cumsum():
A = [1 2 3
     7 8 9
     4 5 6
     1 2 3]

cumsum(A)
ans =
     1     2     3
     8    10    12
    12    15    18
    13    17    21

