Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

nanmax

Maximum ignoring NaN values

Syntax

y = nanmax(X)
Y = nanmax(X1,X2)
y = nanmax(X,[],dim)
[y,indices] = nanmax(...)

Description

y = nanmax(X) is the maximum max of X, computed after removing NaN values.

For vectors x, nanmax(x) is the maximum of the remaining elements, once NaN values are removed. For matrices X, nanmax(X) is a row vector of column maxima, once NaN values are removed. For multidimensional arrays X, nanmax operates along the first nonsingleton dimension.

Y = nanmax(X1,X2) returns an array Y the same size as X1 and X2 with Y(i,j) = nanmax(X1(i,j),X2(i,j)). Scalar inputs are expanded to an array of the same size as the other input.

y = nanmax(X,[],dim) operates along the dimension dim of X.

[y,indices] = nanmax(...) also returns the row indices of the maximum values for each column in the vector indices.

Examples

Find column maxima and their indices for data with missing values:

X = magic(3);
X([1 6:9]) = repmat(NaN,1,5)
X =
   NaN     1   NaN
     3     5   NaN
     4   NaN   NaN
[y,indices] = nanmax(X)
y =
     4     5   NaN
indices =
     3     2     1

See Also

| |

Introduced before R2006a

Was this topic helpful?