cumsum
Cumulative sum along a dimension.
Syntax
Section titled “Syntax”B = cumsum(A)B = cumsum(A, dim)Description
Section titled “Description”Returns an array of the same size as A where each element is the running sum from the start of its row/column up to that position. With no dimension argument, accumulates along the first non-singleton dimension.
Examples
Section titled “Examples”cumsum([1 2 3 4]) % [1 3 6 10]cumsum([1 2; 3 4]) % [1 2; 4 6] column cumulative sumscumsum([1 2; 3 4], 2) % [1 3; 3 7] row cumulative sums