how to average hourly data set.

1 次查看(过去 30 天)
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.

采纳的回答

Titus Edelhofer
Titus Edelhofer 2015-8-16
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 个评论
Titus Edelhofer
Titus Edelhofer 2015-8-17
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);

请先登录,再进行评论。

更多回答(1 个)

Andrei Bobrov
Andrei Bobrov 2015-8-16
编辑:Andrei Bobrov 2015-8-16
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);

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by