number of non-nan values across each element in n-dimensional matrix

조회 수: 3 (최근 30일)
Vesp
Vesp 2016년 7월 7일
댓글: Vesp 2016년 7월 7일
Hello all,
I would like to know how to count the number of non-nan values across each element in a 192x144x8766 matrix. Where the dimensions is representative of days (8766 days). I want a final matrix with the number of non-Nan values for each element across all 8766 days.
For example, count of # of non-nan in 1x1x1:8766 so that I can get a fraction of non-nan values over the 8766 days per element (cell in the matrix).
Thank you for any help on this.
  댓글 수: 2
James Tursa
James Tursa 2016년 7월 7일
편집: James Tursa 2016년 7월 7일
You want the number of non-NaN's in each 192x144 slice? So you would end up with a 8766 element vector? Or do you expect to end up with a 192x144 element matrix result?
Vesp
Vesp 2016년 7월 7일
I would like to end up with a 192x144 element matrix result. So that the number in the final matrix is reflective of the total non-nan values in each cell across all 8766 slices.
Thank you for your response.

댓글을 달려면 로그인하십시오.

채택된 답변

James Tursa
James Tursa 2016년 7월 7일
Is this what you want?
x = your 192x144x8766 array
result = sum(~isnan(x),3);
  댓글 수: 1
Vesp
Vesp 2016년 7월 7일
This worked perfectly! Thank you very much for your timely response :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 7일
b=sum(isnan(A),1)
b=sum(b,2)

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by