p = prod(X)
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.
The product of the elements in each column isM = magic(3)
M =
8 1 6
3 5 7
4 9 2
The product of the elements in each row can be obtained by transposing twice.prod(M) =
96 45 84
prod(M')' =
48
105
72
cumprod
,sum
(c) Copyright 1994 by The MathWorks, Inc.