How can I aggregate rows by a specified start time and time step in a time table?
4 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Guillaume
on 14 Jun 2018
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 Comments
Peter Perkins
on 3 Jul 2018
Edited: Peter Perkins
on 5 Jul 2018
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))
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!