Data coverage per cell of 3D array
11 次查看(过去 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!