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!