MATLAB: How to average time data every 1/4 of hour

averagecumulative averagetime series

Hello Community, I have a problem to average data every quarter of hour. I have to array of the same length. Vector "t" shows the time the data was recorded and vector "x" shows the data values for every t. The data in "x" does not have the same period of recording, generally is every 1 min, but it can jump randomly, for instance, the period between points can change to 4,8 50, 140 minutes. I'm trying to create a loop that averages the data at specific intervals in an hour.
x=[42,15,4,1,5,9,84,7,45,55,77,5,15,...]
t=[01-Jan-2016 22:24:00,01-Jan-2016 22:25:00,01-Jan-2016 22:26:00,01-Jan-2016 23:00:00,01-Jan-2016 23:04:00,01-Jan-2016 23:04:00,....)
So, I'm looking to generate a loop that check if the data is between 0-15 min,15-30 min, 30-45 min,45-0 min and then average the corresponding data of x.
Is there a much better suggestion on how to proceed?
Thanks for all the help

Best Answer

The easiest way is probably to use a timetable() object and call retime(). This requires R2016b or later.
Related Question