How can I aggregate rows by a specified start time and time step in a time table?
2 次查看(过去 30 天)
显示 更早的评论
I have 15-minute schedules and I want to aggregate time steps with given start time using mean, sum, max, and so on. I've already tried to use the retime function, but it only makes the sum to the next full hour and I need the sum of the next hour. For instance the sum of Load for the next hour starting at 14:30 and including the time steps 14:45, 15:00, 15:15 ...
TStep = hours(1);
AggregateSchedule = retime(Schedule,'regular','sum','TimeStep',TStep);
DateTime ID Load RL Price
___________________ __________ ____ __ _____
14.06.2018 14:30:00 7617 6148 0 250
14.06.2018 14:45:00 7617 6253 0 250
14.06.2018 15:00:00 7617 6358 0 250
14.06.2018 15:15:00 7617 6463 0 250
14.06.2018 15:30:00 7617 6568 0 250
14.06.2018 15:45:00 7617 6673 0 250
14.06.2018 16:00:00 7617 6778 0 250
14.06.2018 16:15:00 7617 6883 0 250
Many thanks in advance!
0 个评论
采纳的回答
Guillaume
2018-6-14
My suggestion would be to subtract 30 minutes from your datetime column, retime it as you've done then add the 30 minutes back:
Schedule.Properties.RowTimes = Schedule.Properties.RowTimes - minutes(30);
AggregateSchedule = retime(Schedule, 'hourly', 'sum');
AggregateSchedule.Properties.RowTimes = AggregateSchedule.Properties.RowTimes + minutes(30);
2 个评论
Peter Perkins
2018-7-3
编辑:Peter Perkins
2018-7-5
As I suspect that link describes, retime will happily aggregate on the half-hours, it's just a little bit more work than using 'hourly'. Create an explicit target time vector as something like
target = datetime(2018,6,14,14,30,0):minutes(30):datetime(...)
Also, beginning in R2018a, there's a new syntax to make that easier:
tt = retime(tt,'regular',method,'TimeStep',minutes(30))
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!