Products & Services Industries Academia Support User Community Company

Learn more about Statistics Toolbox   

nanmedian - Median ignoring NaN values

Syntax

y = nanmedian(X)
y = nanmedian(X,dim)

Description

y = nanmedian(X) is the median of X, computed after removing NaN values.

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

y = nanmedian(X,dim) takes the mean along dimension dim of X.

Examples

Find column medians 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 = nanmedian(X)
y =
   3.5000  3.0000  NaN

See Also

NaN, median, nanmean

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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