how to average seasonly?
조회 수: 2 (최근 30일)
이전 댓글 표시
i have data set 141x49x300 (longitude,latitude,time), it contains data monthly average from 1995-2019. which mean 141x49x1 mean jan 1995 and 141x49x300 mean december 2019.
how do make average data every three month (dec, jan, feb) (mar, apr, may) and so on?
thanks
댓글 수: 0
답변 (1개)
dpb
2021년 3월 6일
편집: dpb
2021년 3월 6일
This one is cute... :) Unfortunately, timetable won't accept a 2D array by row so have to do things directly...
t=linspace(datetime(1995,1,1),datetime(1995,12,31),300).'; % 300 elements between above start, stop
[r,c,p]=size(A); % sizes of data, A
M=(splitapply(@mean,reshape(A,r*c,[]).',findgroups(quarter(t)))); % compute means by quarter by columns
M=reshape(M.',r,c,[]); % reshape back to rxcx4
Substitute your real time vector for t, of course.
I did a trial here to check ordering...
t=linspace(datetime(1995,1,1),datetime(1995,12,31)).'; % only 100 instead of 300
A=randi([50 100],5,5,100); % dummy 5x5 data
M=(splitapply(@mean,reshape(A,25,100).',findgroups(quarter(t)))); % compute means 2D
>> M(:,1:3) % small piece to look at to check
ans =
78.4400 76.6000 75.3200
76.3200 73.2400 74.7200
71.6800 76.7200 83.7200
80.6000 74.3600 74.8000
>>
>> MM=reshape(M.',5,5,4);
>> whos MM
Name Size Bytes Class Attributes
MM 5x5x4 800 double
>> squeeze(MM(1,1,:))
ans =
78.44
76.32
71.68
80.60
>> squeeze(MM(2,1,:))
ans =
76.60
73.24
76.72
74.36
>>
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Octave에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!