Skip to content

cumprod

Cumulative product along a dimension.

B = cumprod(A)
B = cumprod(A, dim)

Returns an array of the same size as A where each element is the running product from the start of its row/column up to that position. With no dimension argument, accumulates along the first non-singleton dimension.

cumprod(1:5) % [1 2 6 24 120] factorials
cumprod([1 2; 3 4]) % [1 2; 3 8] column cumulative products
  • prod — Product of array elements.
  • cumsum — Cumulative sum along a dimension.