Effacer les filtres
Effacer les filtres

how to average hourly data set.

1 vue (au cours des 30 derniers jours)
SONI SONI
SONI SONI le 16 Août 2015
Commenté : Titus Edelhofer le 17 Août 2015
I have a three dimensional matrix 180*360*3456
3456 represents time series of 36 years. this is hourly data set, in every month 8 times observations (3:00, 6:00, 9:00, 12:00 15:00, 18:00, 21:00, 00:00) were taken. 8*12=96; 96*36=3456 now I want to take average of each eight hours (3:00, 6:00, 9:00, 12:00 15:00, 18:00, 21:00, 00:00) which will represent a average value of a month. final dimension of matrix will be 180*360*432 (12*36=432). please suggest me a MATLAB code.

Réponse acceptée

Titus Edelhofer
Titus Edelhofer le 16 Août 2015
Hi,
I admit I have no idea where the 180*360 comes from in your "final dimension". But to compute the mean value of each block of 8 samples is easy:
A = rand(3456,1);
% convert to matrix with 8 rows:
A = reshape(A, 8, numel(A)/8);
% the mean now computes the mean for each column:
Amean = mean(A);
Now you have the mean values and can use e.g. repmat if you want to have e.g. 24 hours of each value ...
Titus
  1 commentaire
Titus Edelhofer
Titus Edelhofer le 17 Août 2015
O.K., when I wrote the answer I overlooked the first line of the question :). But the technique stays the same, namely reshaping to a matrix 8x432 (not touching the first two dimensions):
s = size(A);
% change from 180x360x3456 to 180x360x8x432
A = reshape(A, s(1), s(2), 8, s(3)/8);
% compute the mean (along the third dimension)
B = mean(A, 3);
% and change from 180x360x1x432 to 180x360x432:
B = reshape(B, s(1), s(2), s(3)/8);

Connectez-vous pour commenter.

Plus de réponses (1)

Andrei Bobrov
Andrei Bobrov le 16 Août 2015
Modifié(e) : Andrei Bobrov le 16 Août 2015
your_array - double array with size [180 x 360 x 3456]
s = size(your_array);
[ii,jj,k] = ndgrid(1:s(1),1:s(2),1:ceil((1:s(3))/8));
out = accumarray([ii(:),jj(:),k(:)],your_array(:),[],@mean);

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by