prod

Takes the product of elements along dimension dim.

Syntax

R = prod(x)

R = prod(x,dim)

Inputs

x
Any valid matrix.
Type: double | integer | logical
Dimension: matrix
dim
The dimension on which to multiply.
Default: first non-singleton dimension.
Type: integer
Dimension: scalar

Outputs

R
The product of elements for each vector.

Examples

Vector:

R = prod([1,2,3])
R = 6

Matrix with default dimension:

R = prod([1,2,3;1,2,3;1,2,3])
R = [ 1 8 27 ]

Matrix with specified dimension:

R = prod([1,2,3;1,2,3;1,2,3],2)
R = [Matrix] 3 x 1
6
6
6