How can i select daily data with a 15 min partition?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Enrique Escrig
el 5 de Mayo de 2020
Comentada: Enrique Escrig
el 6 de Mayo de 2020
Hi!!
I have a timetable with data of days with a periodicity of 15 min and I want to select different days. At the time of selecting the days that I want, only get the data for the day at 00:00. I want you to take all the data from those selected days.
Thanks in advance
1 comentario
KSSV
el 5 de Mayo de 2020
Read about interp1. Generate your required time arrays and do inteprolation.
Respuesta aceptada
Peter Perkins
el 5 de Mayo de 2020
These two things
"only get the data for the day at 00:00. I want you to take all the data from those selected days"
seem contradictory.
It sounds like you have a timetable that spans multiple days, with 15min time steps. If you want to select only some of those days, and they are contiguous, use timerange as Steve suggests. If the days are not contiguous, use ismember to create a logical vector from the timetable's row times, then use that as a row subscript to select the days of interest.
If you additionally only want the "midnight" rows on those selected days, use timeofday on the timetable's row times to again create a logical vector for subscripting.
If, on the other hand, you want to somehow aggregate all the data from each day into one row whose timestamp is at midnight, use retime with an aggregation, as KSSV suggests.
It would help if you gavce a short clear example of what you have and what you want.
3 comentarios
Peter Perkins
el 5 de Mayo de 2020
Right. You are giving the timetable a datetime subscript, and it selects rows with exact matches. You need to create a logical subscript. Try this:
days_select_mask = ismember(dateshift(TT_all_data.Time,'start','day'),days_select);
TT_days_select = TT_all_data(days_select,:)
Anotehr possibility would be to set all your days_to_select to noon, and use withtol and a tolerance of 12 hours. That's kind of a misuse of withtol, though.
Más respuestas (1)
Steven Lord
el 5 de Mayo de 2020
Index into your timetable with a timerange.
x = randn(100, 1);
N = datetime('now');
t = N + minutes(60*x);
tt = timetable(t, x);
R = timerange(N, N + minutes(15))
next15Minutes = tt(R, :)
To check, compute what x should be from the RowTimes of next15Minutes.
x2 = minutes(next15Minutes.t - N)/60; % Reversing how we created t originally
next15Minutes.x-x2 % Should be close to the zero vector
0 comentarios
Ver también
Categorías
Más información sobre Time Series Events en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!