How to aggregate data on seasonal basis?

1 回表示 (過去 30 日間)
Hydro
Hydro 2017 年 12 月 21 日
コメント済み: Aries Dwi Siswanto 2020 年 4 月 26 日
Hello, My seasons are defined as Dec-Feb, March-May, June-August, and Sep-Nov. My data is organized in Jan-December format with daily time step. the following code will re-arrange the data on a mean seasonal basis in the sequential order (e.g Q1= Jan - March, Q2=April - June), however, in North America season are different as I explained earlier. Can someone suggest a way forward or a code piece of code?
A=rand(730,2);
t1=(datetime(1981,1,1):datetime(1982,12,31))';
TT=timetable(t1,A);
TT2=retime(TT,'quarterly','mean');
Many thanks,
Ameer

採用された回答

Akira Agata
Akira Agata 2018 年 6 月 29 日
You can do that by setting new time vector as the 2nd input variable of retime function, like:
t2 = [datetime(1980,12,1):calmonths(3):datetime(1983,2,1)]';
TT2 = retime(TT,t2,'mean');
The result looks like:
>> TT2
TT2 =
9×1 timetable
t1 A
__________ __________________
1980/12/01 0.55223 0.4327
1981/03/01 0.46912 0.44696
1981/06/01 0.47352 0.46669
1981/09/01 0.51435 0.51787
1981/12/01 0.47761 0.52672
1982/03/01 0.51506 0.50781
1982/06/01 0.51125 0.58926
1982/09/01 0.491 0.52664
1982/12/01 0.84221 0.70557
  3 件のコメント
ugur uresin
ugur uresin 2018 年 7 月 3 日
+1
Aries Dwi Siswanto
Aries Dwi Siswanto 2020 年 4 月 26 日
Hi Andrei Bobrov and Ugur Uresin,
t2 = [datetime(1980,12,1):calmonths(3):datetime(1983,2,1)]';
TT2 = retime(TT,t2,'mean');
Which part will added by 1?
Thank you,

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by