cumprod

The cumulative product of object's elements along a specified dimension.

Syntax

R = cumprod(x)

R = cumprod(x,dim)

Inputs

x
Any valid scalar | vector | matrix.
Type: double | integer | logical | struct | cell
Dimension: scalar | vector | matrix
dim
The dimension on which to accumulate.
Default: first non-singleton dimension.
Type: integer
Dimension: scalar

Outputs

R
The cumulative product.

Examples

Along default dimension:

cumprod([1,2,3;4,5,6])
ans = [Matrix] 2 x 3
1   2   3
4  10  18

Using row dimension:

cumprod([1,2,3;4,5,6],2)
ans = [Matrix] 2 x 3
1   2    6
4  20  120

Comments

Returns the cumulative product starting at the beginning of the first array.