| Contents | Index |
B = prod(A)
B = prod(A,dim)
B = prod(A,'double')
B = prod(A,'native')
B = prod(A) returns the products along different dimensions of an array. A can be double or single. B is multiplied natively, that is in the same class as A, and B has the same class as A.
If A is a vector, prod(A) returns the product of the elements.
If A is a matrix, prod(A) treats the columns of A as vectors, returning a row vector of the products of each column.
If A is a multidimensional array, prod(A) treats the values along the first non-singleton dimension as vectors, returning an array of row vectors.
B = prod(A,dim) takes the products along the dimension of A specified by scalar dim.
B = prod(A,'double') multiplies B in double and B has class double, even if A is single.
B = prod(A,'native') multiplies B natively and B has the same class as A.
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:
prod(M,2) =
48
105
72
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |