How can I aggregate rows by a specified start time and time step in a time table?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
s.h.m_89
el 14 de Jun. de 2018
Editada: Peter Perkins
el 5 de Jul. de 2018
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 comentarios
Respuesta aceptada
Guillaume
el 14 de Jun. de 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 comentarios
Peter Perkins
el 3 de Jul. de 2018
Editada: Peter Perkins
el 5 de Jul. de 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))
Más respuestas (0)
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!