MATLAB Function Reference |

**Syntax**

**Description**

```
B = prod(A)
```

returns the products along different dimensions of an array.

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`

.

**Examples**

The magic square of order 3 is

The product of the elements in each column is

The product of the elements in each row can be obtained by:

**See Also**

printpreview | profile |