max
Maximum elements of array
Syntax
Description
returns the maximum elements of an array.M = max(A)
If
Ais a vector, thenmax(A)returns the maximum ofA.If
Ais a matrix, thenmax(A)is a row vector containing the maximum value of each column ofA.If
Ais a multidimensional array, thenmax(A)operates along the first dimension ofAwhose size does not equal 1, treating the elements as vectors. The size ofMin this dimension becomes1, while the sizes of all other dimensions remain the same as inA. IfAis an empty array whose first dimension has zero length, thenMis an empty array with the same size asA.If
Ais a table or timetable, thenmax(A)returns a one-row table containing the maximum of each variable. (since R2023a)
specifies whether to omit or include missing values in M = max(A,[],___,missingflag)A for
any of the previous syntaxes. For example,
max(A,[],"includemissing") includes all missing values
when computing the maximum. By default, max omits missing
values.
also specifies how to treat missing values.C = max(A,B,missingflag)
___ = max(___,"ComparisonMethod",
optionally specifies how to compare elements for any of the previous syntaxes.
For example, for a vector method)A = [-1 2 -9], the syntax
max(A,[],"ComparisonMethod","abs") compares the elements
of A according to their absolute values and returns a maximum
value of -9.
![max(A,[],1) column-wise operation](max_dim_1.png)
![max(A,[],2) row-wise operation](max_dim_2.png)
