how to average hourly data set.

1 Ansicht (letzte 30 Tage)
SONI SONI
SONI SONI am 16 Aug. 2015
Kommentiert: Titus Edelhofer am 17 Aug. 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.

Akzeptierte Antwort

Titus Edelhofer
Titus Edelhofer am 16 Aug. 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 Kommentar
Titus Edelhofer
Titus Edelhofer am 17 Aug. 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);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Andrei Bobrov
Andrei Bobrov am 16 Aug. 2015
Bearbeitet: Andrei Bobrov am 16 Aug. 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);

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by