Yearly average from monthly data
Afficher commentaires plus anciens
Hello,
It has been a while since I have made any new loops that I have not copied from old scripts, so I am a little out of practice. This question should be fairly easy for most to answer.
I have a data set with monthly data:
Size(A)=192,144,120
I would like to put this into ten, yearly averages:
Size(B)=192,144,10
I have just done it the long way around-
B(:,:,1)=mean(A(:,:,1:12),3);
B(:,:,2)=mean(A(:,:,13:24),3);
B(:,:,3)=mean(A(:,:,25:36),3);
B(:,:,4)=mean(A(:,:,37:48),3);
B(:,:,5)=mean(A(:,:,49:60),3);
B(:,:,6)=mean(A(:,:,61:72),3);
B(:,:,7)=mean(A(:,:,73:84),3);
B(:,:,8)=mean(A(:,:,85:96),3);
B(:,:,9)=mean(A(:,:,97:108),3);
B(:,:,10)=mean(A(:,:,109:120),3);
This works fine, but is a little tedious and I will be wanting to do this with much larger data sets in the coming months.
What is the best way to do this in a for loop?
Thank you!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!