y = max(X)[y,i] = max(X)C = max(A,B)
max(X) is the largest element in X. For matrices, max(X) is a row vector containing the maximum element from each column and max(max(X)) is the largest element in the entire matrix.
[y,i] = max(X) stores the indices of the maximum values in vector i. If there are several identical maximum values, the index of the first one found is returned.
C = max(A,B) returns a matrix the same size as A and B with the largest elements taken from A or B.
For complex input X, max returns the complex number with the largest modulus, computed with max(abs(X)).
If any element of the matrix is a NaN, max returns NaN. To test for this occurrence, use the function isnan.
A = magic(3):
ThenA=8 1 63 5 74 9 2
max(A) is the vector
8 9 7
and max(max(A)) is scalar
9
Furthermore, [m,i] = max(A) produces
m=8 9 7i=1 3 2
isnan,min,sort
(c) Copyright 1994 by The MathWorks, Inc.