Documentation

nanmedian

Median ignoringNaNvalues

Syntax

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

Description

y = nanmedian(X)is themedianofX, computed after removingNaNvalues.

For vectorsx,nanmedian(x)is the median of the remaining elements, onceNaNvalues are removed. For matricesX,nanmedian(X)is a row vector of column medians, onceNaNvalues are removed. For multidimensional arraysX,nanmedianoperates along the first nonsingleton dimension.

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

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

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

||

Introduced before R2006a

Was this topic helpful?