Borrar filtros
Borrar filtros

NaN data treatment: can I get a mean f a vector including NaN?

2 visualizaciones (últimos 30 días)
etcann
etcann el 18 de Feb. de 2012
Hello,
The title says it all. Can I get a mean of a vector including NaN? For instance, a= [1 2 3 NaN 4 5] mean(a) usually gives NaN. But I wonder if there is any command or way to get a mean of 3 there. 1. NaN is treated to be missing so that is counted as zero and 2. 1+2+3+4+5 is divided by 5 not by six, which counts NaN.
Thanks

Respuestas (1)

Walter Roberson
Walter Roberson el 18 de Feb. de 2012
nanmean() if you have the stats toolbox. If you do not there is a File Exchange Contribution with a title similar to "nantools"

Categorías

Más información sobre NaNs en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by