Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Cumulative product

`B = cumprod(A)`

`B = cumprod(A,dim)`

`B = cumprod(___,direction)`

`B = cumprod(___,nanflag)`

returns
the cumulative product of `B`

= cumprod(`A`

)`A`

starting at the beginning
of the first array dimension in `A`

whose size does
not equal 1.

If

`A`

is a vector, then`cumprod(A)`

returns a vector containing the cumulative product of the elements of`A`

.If

`A`

is a matrix, then`cumprod(A)`

returns a matrix containing the cumulative products for each column of`A`

.If

`A`

is a multidimensional array, then`cumprod(A)`

acts along the first nonsingleton dimension.

Many cumulative functions in MATLAB

^{®}support the`'reverse'`

option. This option allows quick directional calculations without needing a flip or reflection of the input array.

Was this topic helpful?