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!