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 CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by