Getting a mean of only the numbers

4 visualizaciones (últimos 30 días)
Evelyn
Evelyn el 9 de Oct. de 2014
Comentada: Evelyn el 9 de Oct. de 2014
I have a dataset and I want the mean value of the numbers. There are a lot of NaN-values in there and I want to ignore those (the code
mean(data)
now gives 'NaN' as answer) How do I do this?

Respuesta aceptada

Mischa Kim
Mischa Kim el 9 de Oct. de 2014
Evelyn, use
mean(data(~isnan(data)))

Más respuestas (1)

Thorsten
Thorsten el 9 de Oct. de 2014
Use nanmean
  1 comentario
Mischa Kim
Mischa Kim el 9 de Oct. de 2014
That's another option. You need to have access to the Statistics Toolbox though.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by