Skip to content

prod

Product of array elements.

B = prod(A)
B = prod(A, dim)

Returns the product of A’s elements. With no dimension argument, multiplies along the first non-singleton dimension. With dim, multiplies along that dimension. NaN values cause the product to be NaN.

prod([1 2 3 4]) % 24
prod([1 2; 3 4]) % [3 8] column products
prod([1 2; 3 4], 2) % [2; 12] row products
  • sum — Sum elements of an array.
  • cumprod — Cumulative product along a dimension.