prod

Purpose

Product of matrix elements.

Synopsis

p = prod(X)

Description

prod(X), where X is a vector, is the product of the elements of X. For matrices, prod(X) is a row vector with the product over each column.

Examples

The magic square of order 3 is

M = magic(3)
          
M = 
    8    1    6
    3    5    7
    4    9    2 
The product of the elements in each column is

prod(M) = 
    96    45    84 
The product of the elements in each row can be obtained by transposing twice.

prod(M')' = 
     48
    105
     72

See Also

cumprod, sum

(c) Copyright 1994 by The MathWorks, Inc.