Effacer les filtres
Effacer les filtres

How do I take the average of every n values in a matrix?

1 vue (au cours des 30 derniers jours)
roberto ivan perez luna
roberto ivan perez luna le 2 Déc 2017
Modifié(e) : Matt J le 2 Déc 2017
hello again, i have one a2_dap_U 17567x71x42 double value matrix; 17567=values every 30 min, 71x42 grid.
so i tried this one for the 24 hour average (48 since its every 30 min):
a2_dap_U_24=arrayfun(@(i) nanmean(a2_dap_U(i:i+48-1)),1:48:length(a2_dap_U)-48+1)';
but it gave me 365 NaN values, and i dont know how to do it, since this command line help me with individual values that i extracted from two sites within the 71x42 matrix, but it doesnt help me for the whole 17567 values for the whole matrix.
any help please ;)

Réponses (1)

Matt J
Matt J le 2 Déc 2017
Modifié(e) : Matt J le 2 Déc 2017
a2_dap_U(17568,:,:)=nan; %pad to even multiple of 48
A=nanmean(reshape(a2_dap_U,48,[]));
B=reshape(A,[],71,42);

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by