nanmedian
R2026b(Not recommended) Median, ignoring NaN values
nanmedian is not recommended. Use the MATLAB® function median instead. With the median function, you can specify
whether to include or omit NaN values for the calculation. For more
information, see Version History.
Description
returns
the y = nanmedian(X)median of the elements of
X, computed after removing all NaN values.
If
Xis a vector, thennanmedian(X)is the median of all the non-NaNelements ofX.If
Xis a matrix, thennanmedian(X)is a row vector of column medians, computed after removingNaNvalues.If
Xis a multidimensional array, thennanmedianoperates along the first nonsingleton dimension ofX. The size of this dimension becomes 1 while the sizes of all other dimensions remain the same.nanmedianremoves allNaNvalues.
returns the median over the dimensions specified in the vector y = nanmedian(X,vecdim)vecdim.
The function computes the medians after removing NaN values. For example,
if X is a matrix, then nanmedian(X,[1 2]) is the
median of all non-NaN elements of X, because every
element of a matrix is contained in the array slice defined by dimensions 1 and 2.
