max
Maximum value along a dimension, or elementwise maximum of two inputs.
Syntax
Section titled “Syntax”m = max(A)m = max(A, [], dim)C = max(A, B)[m, i] = max(A)Description
Section titled “Description”With one argument, returns the maximum value of A — for vectors, the largest element; for matrices, a row vector of column maxes; for higher-dimensional arrays, the maxes along the first non-singleton dimension. The optional second return value is the index of the maximum.
With two arguments, returns the elementwise maximum of A and B (broadcasting compatible shapes).
With three arguments and the second equal to [], returns the maxes along dimension dim.
When A is a graph handle, returns the maximum of the graph’s data points. In Excel-compatible mode and when any argument is a cell range, the function reduces the entire range to a scalar.
Examples
Section titled “Examples”max([3 1 4 1 5 9 2 6]) % 9max(magic(3)) % [8 9 7] column maxesmax(magic(3), [], 2) % [8;7;9] row maxesmax([1 5 3], [4 2 3]) % [4 5 3] elementwiseSee also
Section titled “See also”min— Minimum value along a dimension, or elementwise minimum of two inputs.isequal— Test whether two or more inputs are equal in shape and value.
Also categorized under: Range Functions / Math.