Data coverage per cell of 3D array
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a 3D data array of size 150 x 75 x 730 (lat x lon x time (days). Data coverage for each day (3rd dimension) varies with NAN values representing no data.
How do I calculate the data coverage in each cell for the total time duration? I want to use this to select cells with suffiicient data coverage.
채택된 답변
Voss
2022년 4월 8일
% create a 3D matrix data with 15000 elements
data = rand(15,10,100);
% put NaNs at 7500 random indices (which may have repeats)
data(randi(numel(data),7500,1)) = NaN;
% this many elements of data are NaN:
nnz(isnan(data))
% data coverage is the total number of non-NaN elements
% at each (x,y) point, where x and y correspond to the
% first 2 dimensions of data.
% sum ~isnan(data) over the third dimension to find
% the data coverage:
data_coverage = sum(~isnan(data),3);
disp(data_coverage);
% say sufficient data coverage is >= 60 non-NaNs
has_sufficient_data = data_coverage >= 60 % using the number of non-NaNs
% which is the same as <= 40 NaNs:
has_sufficient_data = sum(isnan(data),3) <= 40 % using the number of NaNs
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 NaNs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!