MATLAB Function Reference
  Go to function:
    Search    Help Desk 
cumsum    Examples   See Also

Cumulative sum

Syntax

Description

B = cumsum(A) returns the cumulative sum along different dimensions of an array.

If A is a vector, cumsum(A) returns a vector containing the cumulative sum of the elements of A.

If A is a matrix, cumsum(A) returns a matrix the same size as A containing the cumulative sums for each column of A.

If A is a multidimensional array, cumsum(A) works on the first nonsingleton dimension.

B = cumsum(A,dim) returns the cumulative sum of the elements along the dimension of A specified by scalar dim. For example, cumsum(A,1) works across the first dimension (the rows).

Examples

See Also

sum         Sum of array elements

prod        Product of array elements

cumprod     Cumulative product of elements



[ Previous | Help Desk | Next ]