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.
0 件のコメント
採用された回答
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
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
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);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!