Next: spmin, Previous: splu, Up: Function Reference
For a vector argument, return the maximum value. For a matrix argument, return the maximum value from each column, as a row vector, or over the dimension dim if defined. For two matrices (or a matrix and scalar), return the pair-wise maximum. Thus,
max (max (x))returns the largest element of x, and
max (2:5, pi) => 3.1416 3.1416 4.0000 5.0000compares each element of the range
2:5
withpi
, and returns a row vector of the maximum values.For complex arguments, the magnitude of the elements are used for comparison.
If called with one input and two output arguments,
max
also returns the first index of the maximum value(s). Thus,[x, ix] = max ([1, 3, 5, 2, 5]) => x = 5 ix = 3