min

Purpose

Minimum elements of a matrix.

Synopsis

y = min(X)
[y,i] = min(X)
C = min(A,B)

Description

min(X), where X is a vector, is the smallest element in X. For matrices, min(X) is a row vector containing the minimum element from each column and min(min(X)) is the smallest element in the entire matrix.

[y,i] = min(X) stores the indices of the minimum values in vector i. If there are several identical minimum values, the index of the first one found is returned.

C = min(A,B) returns a matrix the same size as A and B with the smallest elements taken from A or B.

For complex input X, min returns the complex number with the smallest modulus, computed with min(abs(X)).

For matrices, if a column of X contains a NaN, the element of the answer corresponding to that column will be NaN.

For vectors, if any element of X is NaN, the answer will be NaN.

Examples

Start with A = magic(3)

 A =
    8    1    6
    3    5    7
    4    9    2
Then min(A) is the vector

    3    1    2
and min(min(A)) is the scalar

 1
Furthermore, [m,i] = min(A) produces

 m =
    3    1    2
          
 i =
    2    1    3

See Also

isnan, max, sort

(c) Copyright 1994 by The MathWorks, Inc.