Dealing with NaN values when compressing matrix

1 回表示 (過去 30 日間)
Ahmed Abdulla
Ahmed Abdulla 2020 年 6 月 8 日
コメント済み: Ahmed Abdulla 2020 年 6 月 8 日
I have 1000 by 1000 matrix and i want to convert it into a 10x10 matrix, ive found several way on the community that does this. However my matrices contain some cells that are NaN so when the all the values gets added to get averaged for compression the NaN cells force this calculation to yield NaN and so the compressed cell is equal to NaN.
for example if 10 cells are to be averaged and one of them is NaN, is there a way to make it add the 9 values and divide by 9 rather than 10

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 6 月 8 日
You can pass omitnan to mean() to ignore NaN values
mean(x, 'all', 'omitnan')
  1 件のコメント
Ahmed Abdulla
Ahmed Abdulla 2020 年 6 月 8 日
Thank you, i just read about this on the mean documnetation and it worked!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by