daily data into weekly mean for whole year
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Haa Andrew
le 7 Sep 2017
Modifié(e) : Andrei Bobrov
le 7 Sep 2017
I have 3D matrix 100x150x365 (Column 3 shows number of days). I want to get weekly mean in loop with same first two dimensions. At the end I need 100x150x53 (53 weeks). Please share your experience to solve this problem.
0 commentaires
Réponse acceptée
Andrei Bobrov
le 7 Sep 2017
Modifié(e) : Andrei Bobrov
le 7 Sep 2017
Let A - your array
[m,n,k] = size(A);
p = 7;
i3 = ceil((1:k)'/p);
[ii,jj,kk] = ndgrid(1:m,1:n,i3);
out = accumarray([ii(:),jj(:),kk(:)],A(:),[],@mean);
2 commentaires
Andrei Bobrov
le 7 Sep 2017
Modifié(e) : Andrei Bobrov
le 7 Sep 2017
in my case: first week -> out(:,:,1); second week -> out(:,:,2) and etc.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!