nanmax - Maximum ignoring NaNs

Syntax

M = nanmax(A)
M = nanmax(A,B)
M = nanmax(A,[],dim)
[M,ndx] = nanmax(...)

Description

M = nanmax(A) returns the maximum with NaNs treated as missing. For vectors, nanmax(A) is the largest non-NaN element in A. For matrices, nanmax(A) is a row vector containing the maximum non-NaN element from each column. For N-dimensional arrays, nanmax operates along the first nonsingleton dimension of X.

M = nanmax(A,B) returns an array of the same size as A and B, each of whose entries is the maximum of the corresponding entries of A or B. A scalar input is expanded to an array of the same size as the other input.

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

[M,ndx] = nanmax(...) also returns the indices of the maximum values in the vector ndx.

Example

A = magic(3);
A([1 6 8]) = [NaN NaN NaN]
A =
  NaN   1   6
   3   5  NaN
   4  NaN   2

[nmax,maxidx] = nanmax(A)
nmax =
   4   5   6
maxidx =
   3   2   1

See Also

nanmin, nanmean, nanmedian, nanstd, nansum

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS