[TOC]

prod

Product of elements in an array

Usages

p = prod(A)

p = prod(A, k)

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

Examples

Input
% A random array.
a = rand(3,4,5,6,7,1,2);
% Product of all elements in the size vector.
n = prod(size(a))
% Using the built-in function numel.
numel(a)
Output
n = 
 5040.0

ans = 
 5040.0