Getting a mean of only the numbers

3 ビュー (過去 30 日間)
Evelyn
Evelyn 2014 年 10 月 9 日
コメント済み: Evelyn 2014 年 10 月 9 日
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 日
Evelyn, use
mean(data(~isnan(data)))
  1 件のコメント
Evelyn
Evelyn 2014 年 10 月 9 日
Thank you so much!

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

その他の回答 (1 件)

Thorsten
Thorsten 2014 年 10 月 9 日
Use nanmean
  1 件のコメント
Mischa Kim
Mischa Kim 2014 年 10 月 9 日
That's another option. You need to have access to the Statistics Toolbox though.

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

カテゴリ

Help Center および File ExchangeHypothesis Tests についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by