Getting a mean of only the numbers

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?

 採用された回答

Mischa Kim
Mischa Kim 2014 年 10 月 9 日

1 投票

Evelyn, use
mean(data(~isnan(data)))

1 件のコメント

Evelyn
Evelyn 2014 年 10 月 9 日
Thank you so much!

サインインしてコメントする。

その他の回答 (1 件)

Thorsten
Thorsten 2014 年 10 月 9 日

1 投票

Use nanmean

1 件のコメント

Mischa Kim
Mischa Kim 2014 年 10 月 9 日
That's another option. You need to have access to the Statistics Toolbox though.

サインインしてコメントする。

タグ

質問済み:

2014 年 10 月 9 日

コメント済み:

2014 年 10 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by