Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Maximum elements of an array

`M = max(A)`

`M = max(A,[],dim)`

`M = max(A,[],nanflag)`

`M = max(A,[],dim,nanflag)`

```
[M,I] =
max(___)
```

`M = max(A,[],'all')`

`M = max(A,[],vecdim)`

`M = max(A,[],'all',nanflag)`

`M = max(A,[],vecdim,nanflag)`

`C = max(A,B)`

`C = max(A,B,nanflag)`

returns the maximum elements of an array.`M`

= max(`A`

)

If

`A`

is a vector, then`max(A)`

returns the maximum of`A`

.If

`A`

is a matrix, then`max(A)`

is a row vector containing the maximum value of each column.If

`A`

is a multidimensional array, then`max(A)`

operates along the first array dimension whose size does not equal`1`

, treating the elements as vectors. The size of this dimension becomes`1`

while the sizes of all other dimensions remain the same. If`A`

is an empty array whose first dimension has zero length, then`max(A)`

returns an empty array with the same size as`A`

.