Finding the mean of every 24 elements of 3rd dimension of a 3d array
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have hourly weather data from 2000-2005 for an area giving a 241x121x52608 array. I am trying to condense the data down into the daily mean and so I'm looking to maintain the 241x121 matrix which denotes the location while condensing the 52608/24 into 2192 days in total (Including leap years)
I'm sure there is a simple way to do this but I'm new to Matlab so I'm struggling to come up with a solution.
Thanks
0 commentaires
Réponse acceptée
Fangjun Jiang
le 13 Juil 2022
Modifié(e) : Fangjun Jiang
le 13 Juil 2022
Something like this. Try simple example to make sure the dimension, row, column are right.
a=ones(2,3,10);
b=mean(reshape(a,2,3,2,[]),4)
3 commentaires
Fangjun Jiang
le 13 Juil 2022
There are multiple ways. One example below. See doc for the arguments of calling reshape() and mean()
a=rand(2,3,10);
b=mean(reshape(a,2,3,5,[]),3);
b(1,1,1)
c=a(1,1,:);
d=c(1,1,1)+c(1,1,2)+c(1,1,3)+c(1,1,4)+c(1,1,5);
e=d/5
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing 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!