Note: This page has been translated by MathWorks. Please click here

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

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

Largest elements in array

`M = max(A)`

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

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

`C = max(A,B)`

`___ = max(___,nanflag)`

returns
the largest elements of `M`

= max(`A`

)`A`

.

If

`A`

is a vector, then`max(A)`

returns the largest element 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`

.

`___ = max(___,`

specifies
whether to include or omit `nanflag`

)`NaN`

values in the calculation
for any of the previous syntaxes. For the single input case, to specify `nanflag`

without
specifying `dim`

, use `max(A,[],nanflag)`

.
For example, `max(A,[],'includenan')`

includes all `NaN`

values
in `A`

while `max(A,[],'omitnan')`

ignores
them.

Was this topic helpful?