This is machine translation

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

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


Mean ignoring NaNs


m = nanmean(X)
m = nanmean(X,DIM)



Financial times series object.


Dimension along which the operation is conducted.


nanmean for financial times series objects is based on the Statistics and Machine Learning Toolbox™ function nanmean. See nanmean.

m = nanmean(X) returns the sample mean of a financial time series object X, treating NaNs as missing values. m is a row vector containing the mean value of the non-NaN elements in each series.

m = nanmean(X,DIM) takes the mean along dimension DIM of X.


To compute nanmean for the following dates:

dates = {'01-Jan-2007';'02-Jan-2007';'03-Jan-2007'};
f = fints(dates, magic(3));
f.series1(1) = nan;
f.series2(3) = nan;
f.series3(2) = nan;

nmean = nanmean(f)
nmean =

    3.5000    3.0000    4.0000

Introduced before R2006a

Was this topic helpful?