how to find the hourly average of datetime series

Hello everyone. I have a datetime series of this form for about 1 month
Dates =datetime(Dates,'InputFormat','dd-MM-yyyy HH:mm:ss')
The variables in the table
Data.Dates
Data.Records1
Data.Records2
I have data for a month at 3 mins intervals.
I visualized plots for the whole time series but I am having troubles visualizing daily averages. 12 to 12 or something like that.
Is it possible to make daily average in hours from this time series into another table with 3 variables?
Thanks in advance

 Respuesta aceptada

Scott MacKenzie
Scott MacKenzie el 28 de Jul. de 2021
Editada: Scott MacKenzie el 28 de Jul. de 2021
TT1 = table2timetable(Data);
TT2 = retime(TT1, 'hourly', 'mean'); % hourly averages
TT3 = retime(TT1, 'daily', 'mean'); % daily averages

3 comentarios

Thank you Scott, this converts all to hourly or daily figures but what I was actually looking for was to see the hourly averages for all hours and daily averages for each day of the week of the datetime series
for Example say we have a timetable with 2 variables, this is how I want them to loook like:
Time Average Data
00:00 2.45
01:00 5.45
02:00 6.32
03:00 4.75
.............................
Day Average Data
Monday 100.19
Tuesday 98.65
Wednesday 78.34
....................................
I hope this is something possible
@Daniel Abraham You state: I was actually looking for was to see the hourly averages for all hours
That's exactly what this line does:
TT2 = retime(TT1, 'hourly', 'mean');
Of course, the line is terminated with a semicolon, so nothing is actually "seen".
You also state: and daily averages for each day of the week of the datetime series
And that's what the following line does:
TT3 = retime(TT1, 'daily', 'mean');
In your example, you include the name of the weekday. If you want to add the weekday name, then add the following:
[~, name] = weekday(TT3.Var1, 'long');
TT3.Weekday = cellstr(name);
If this isn't what you are looking for, please explain further.
Also, it would help if you post your data.
thank you, it works perfectly

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import and Export en Centro de ayuda y File Exchange.

Preguntada:

el 28 de Jul. de 2021

Comentada:

el 3 de Ag. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by