MATLAB Function Reference
  Go to function:
    Search    Help Desk 
max    See Also

Maximum elements of an array

Syntax

Description

C = max(A) returns the largest elements along different dimensions of an array.

If A is a vector, max(A) returns the largest element in A.

If A is a matrix, max(A) treats the columns of A as vectors, returning a row vector containing the maximum element from each column.

If A is a multidimensional array, max(A) treats the values along the first non-singleton dimension as vectors, returning the maximum value of each vector.

C = max(A,B) returns an array the same size as A and B with the largest elements taken from A or B.

C = max(A,[],dim) returns the largest elements along the dimension of A specified by scalar dim. For example, max(A,[],1) produces the maximum values along the first dimension (the rows) of A.

[C,I] = max(...) finds the indices of the maximum values of A, and returns them in output vector I. If there are several identical maximum values, the index of the first one found is returned.

Remarks

For complex input A, max returns the complex number with the largest modulus, computed with max(abs(A)). The max function ignores NaNs.

See Also

isnan       Detect Not-A-Number (NaN)

mean        Average or mean values of array

median      Median values of array

min         Minimum elements of an array

sort        Sort elements in ascending order



[ Previous | Help Desk | Next ]