Data coverage per cell of 3D array
11 views (last 30 days)
Show older comments
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.
Accepted Answer
Voss
on 8 Apr 2022
% 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 Comments
More Answers (0)
See Also
Categories
Find more on NaNs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!