How can I select data of an specific hour of each day on a time series sampled every 5 minutes ?
조회 수: 6 (최근 30일)
이전 댓글 표시
I have my data in a table and separated in two columns. The first colum is a datetime column that contains the date and the time of each day of a year for data sampled every 5 minutes (f example: 01-Jan-2014 00:05:00 , 01-Jan-2014 00:10:00 ... 31-Dec-2014 23:55:00) and in the second column I have my Temperature data. With the groupsummary function I have managed to calculate hourly, daily, monthly and yearly means specifying "hour", "day" or "month" on the input arguments but now, I would like to know if I can choose with this function (or with any other) the data of an specific hour of each day, for example, the temperature data of each day at 2:00 am to compare it with the data of a satelite obtaining the 365 temperature values of every single day at 2:00 am of the year.
Thanks for your time.
댓글 수: 2
Siddharth Bhutiya
2022년 4월 5일
I dont see a way to do this directly, but you can use subscripting to get the desired subset and then use groupsummary on the subset timetable
>> head(tt)
dt Temp
____________________ ________
01-Jan-2014 00:00:00 0.21896
01-Jan-2014 01:00:00 0.047045
01-Jan-2014 02:00:00 0.67886
01-Jan-2014 03:00:00 0.6793
01-Jan-2014 04:00:00 0.93469
01-Jan-2014 05:00:00 0.3835
01-Jan-2014 06:00:00 0.51942
01-Jan-2014 07:00:00 0.83097
>> tt2am = tt(hour(tt.dt) == 2,:);
>> head(tt2am)
dt Temp
____________________ _______
01-Jan-2014 02:00:00 0.67886
02-Jan-2014 02:00:00 0.7622
03-Jan-2014 02:00:00 0.16651
04-Jan-2014 02:00:00 0.7702
05-Jan-2014 02:00:00 0.17833
06-Jan-2014 02:00:00 0.23991
07-Jan-2014 02:00:00 0.9611
08-Jan-2014 02:00:00 0.36534
>> groupsummary(tt2am,'Temp')
ans =
365×2 table
Temp GroupCount
_________ __________
0.0004036 1
0.0016643 1
0.012213 1
0.015499 1
0.018916 1
0.022251 1
0.022677 1
0.026834 1
0.03004 1
0.030504 1
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!