Data coverage per cell of 3D array
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
1 commentaire
Réponse acceptée
Voss
le 8 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur NaNs dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!