Skip to content

max

Maximum value along a dimension, or elementwise maximum of two inputs.

m = max(A)
m = max(A, [], dim)
C = max(A, B)
[m, i] = max(A)

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.

max([3 1 4 1 5 9 2 6]) % 9
max(magic(3)) % [8 9 7] column maxes
max(magic(3), [], 2) % [8;7;9] row maxes
max([1 5 3], [4 2 3]) % [4 5 3] elementwise
  • 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.