How can I average datetimes of my array?

37 Ansichten (letzte 30 Tage)
Madeleine Loveday
Madeleine Loveday am 18 Apr. 2019
I think this may be a simple problem so hopefully someone can help me!
I have datetime values for every 10 seconds of every day for a few years of black carbon values
I'd like to average these to hourly intervals, so that i can correlate this data with data from another array which is in 30 sec intervals
I'm sure i need to use array2timetable and make a timetable to average the data.
The time values are currently in date time format.
I'm attempting to do this on one day at first, this is my data in a table, i cant seem to get it in an array
mytable =
1182×2 table
x1 y1
____________________ ________
23-Jun-2017 10:43:50 4.6948
23-Jun-2017 10:44:00 27.012
23-Jun-2017 10:44:10 36.513
23-Jun-2017 10:44:20 15.741
23-Jun-2017 10:44:30 3.7222
23-Jun-2017 10:44:40 6.0609
23-Jun-2017 10:44:50 8.8386
23-Jun-2017 10:45:00 4.0301
23-Jun-2017 10:45:10 1.8601
23-Jun-2017 10:45:20 3.294
23-Jun-2017 10:45:30 2.7862
23-Jun-2017 10:45:40 2.0448
23-Jun-2017 10:45:50 2.5459
This is an example of what data looks like, for this day it runs from 10:00-14:00.
Thanks!

Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 18 Apr. 2019
Look at the retime() function for a timetable.

Weitere Antworten (2)

Steven Lord
Steven Lord am 18 Apr. 2019
Convert your table to a timetable using table2timetable. Once you have your timetable call retime on it.
  3 Kommentare
Walter Roberson
Walter Roberson am 18 Apr. 2019
Bearbeitet: Walter Roberson am 18 Apr. 2019
No, using a timetable and retime() is the simplest. It is not the only way, but it is designed for exactly this kind of purpose and automatically takes care of issues such as irregular spacing of data points, and missing intervals, and so on. Can't get much simpler than
output = retime(table2timetable(mytable), 'hourly', 'mean');
Madeleine Loveday
Madeleine Loveday am 19 Apr. 2019
Ok great thanks for your help!

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 18 Apr. 2019
Not array2timetable. Use table2timetable

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by