How to divide timeseries data into seasonal variation

6 ビュー (過去 30 日間)
Niraj Acharya
Niraj Acharya 2019 年 9 月 8 日
回答済み: Guillaume 2019 年 9 月 9 日
This is the first instant of my data.
DateTime Global_active_power Global_reactive_power Voltage Global_intensity Sub_metering_1 Sub_metering_2 Sub_metering_3
1/01/2007 0:00 2.58 0.136 241.97 10.6 0 0 0
I want to divide it into summe and winter data.
  2 件のコメント
Guillaume
Guillaume 2019 年 9 月 8 日
What is your definition of summer and winter (when do they start and end)?
Niraj Acharya
Niraj Acharya 2019 年 9 月 8 日
編集済み: Niraj Acharya 2019 年 9 月 8 日
June, July and August are summer while December, January and February are winter. I have list of date in this form:
DateTime
1/1/2007 0.00
1/2/2007 1.00
1/3/2007 1.10
........

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

回答 (1 件)

Guillaume
Guillaume 2019 年 9 月 9 日
Note that if you're indeed using timeseries, you may be better off using timetables instead. They're slightly easier to use and are more powerful.
The following applies to timetables, I believe it's more or less the same syntax for timeseries.
While you can indeed split the data into winter and summer (and discard the rest):
summer = yourtimetable(ismember(month(yourtimetable.DateTime), 6:8), :); %6 to 8 is June, July, August
winter = yourtimetable(ismember(month(yourtimetable.DateTime), [1, 2, 12]), :); %1, 2, 12 is January, February, December
you may be better off adding a new variable named Season of type categorical:
yourtimetable.Season = discretize(mod(month(yourtimetable.DateTime), 12), 0:3:12, 'categorical', {'winter', 'spring', 'summer', 'autumn'}); %the mod is to bring december as first month
you can then do group calculation by season with e.g. groupsummary.

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by