Main Content

(Not recommended) Minimum, ignoring `NaN`

values

`nanmin`

is not recommended. Use the MATLAB^{®} function `min`

instead. With the `min`

function, you can specify whether
to include or omit `NaN`

values for the calculation. For more information,
see Compatibility Considerations.

`y = nanmin(X)`

is the minimum `min`

of `X`

, computed after removing `NaN`

values.

For vectors `x`

, `nanmin(x)`

is the minimum of the
remaining elements, once `NaN`

values are removed. For matrices
`X`

, `nanmin(X)`

is a row vector of column minima,
once `NaN`

values are removed. For multidimensional arrays
`X`

, `nanmin`

operates along the first nonsingleton
dimension.

`y = nanmin(X,[],dim)`

operates along the dimension
`dim`

of `X`

.

`[y,indices] = nanmin(___)`

also
returns the row indices of the minimum values for each column in the vector
`indices`

.

`y = nanmin(X,[],'all')`

returns the minimum of all elements of
`X`

, computed after removing `NaN`

values.

`y = nanmin(X,[],vecdim)`

returns the minimum over the dimensions
specified in the vector `vecdim`

, computed after removing
`NaN`

values. Each element of `vecdim`

represents a
dimension of the input array `X`

. The output `y`

has
length 1 in the specified operating dimensions. The other dimension lengths are the same
for `X`

and `y`

. For example, if `X`

is
a 2-by-3-by-4 array, then `nanmin(X,[],[1 2])`

returns a 1-by-1-by-4
array. Each element of the output array is the minimum of the elements on the
corresponding page of `X`

.

`Y = nanmin(X1,X2)`

returns an array `Y`

the same
size as `X1`

and `X2`

with ```
Y(i,j) =
nanmin(X1(i,j),X2(i,j))
```

. Scalar inputs are expanded to an array of the same
size as the other input.