Cumsum
Cumulative sum
Syntax
cumsum(x) |
x is a matrix |
If x is a vector, then cumsum(x) returns a vector containing the cumulative sum of the elements of x. If x is a matrix, then cumsum(x) returns a matrix containing the cumulative sums for each column of x. |
cumsum(x, n) |
x is a matrix, n is either 1 or 2 |
cumsum(x, n) returns the cumulative sum of the elements along dimension dim. cumsum(x,1) returns the cumulative sum of each column. cumsum(x,2) returns the cumulative sum of each row. |
Examples
Input |
Output |
cumsum([1, 2, 3, 4]) |
|
cumsum([1; 2; 3; 4]) |
|
cumsum([1, 3, 4; 2, 4, 6]) |
|
cumsum([1, 3, 4; 2, 4, 6], 1) |
|
cumsum([1, 3, 4; 2, 4, 6], 2) |
See Also
Created with the Personal Edition of HelpNDoc: Full-featured Documentation generator