daily data into weekly mean for whole year

7 vues (au cours des 30 derniers jours)
Haa Andrew
Haa Andrew 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.

Réponse acceptée

Andrei Bobrov
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
Haa Andrew
Haa Andrew le 7 Sep 2017
Thank you for quick response, your answer in right in your own way but I want week-wise mean data. like 100x150x1 (First week), 100x150x1 (second week). simply i need week-wise separately data.. is it possible?
Andrei Bobrov
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 기초 수학 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!