Skip to content


Product of elements.

P = prod(A)

  • If A is a scalar, P is equal to A.
  • Otherwise, each element of P is the product of all elements of the corresponding vector of A along the first non-singleton dimension.

P = prod(A, k)

  • This is the same as the previous cases, except that each element of P corresponds to a vector of A along its k-th dimension.
  • k should be less than or equal to the number of dimensions of A.


When multiplying two numbers by prod, if any one of them is NaN, the result will be NaN.