MATLAB: Average every 6hrs of hourly values – one month of data with missing data

averaging 6-hrly data

Hi,
I have a one month of data in .txt format. I want to take the average for each 6 hrs (00:00:00 to 05:59:00) for each day (30 days). but I have missing data in between. Here is the format of the data file.
2014-04-01 00:00:00 1.06
2014-04-01 00:02:00 1.05
.
.
2014-04-02 00:00:00 2.05
.
2014-04-30 00:23:59 1.06
Any idea?
Thanks,

Best Answer

Assuming that readtable detects the format of your file properly, it would be as simple as:
t = table2timetable(readtable('yourfile.txt'));
newt = retime(t, 'Regular', 'mean', 'TimeStep', hours(6));
If readtable fails to detect the format correctly, it may need some hints to decode the file properly. It shouldn't be too hard to adjust for your file.