MATLAB: CONVERTING 6 HOURLY DATA TO DAILY DATA

6 hourlyMATLAB

I have 6 hourly data in following format:
01.01.1990-00:00:00 60
01.01.1990-06:00:00 70
01.01.1990-12:00:00 100
01.01.1990-18:00:00 70
01.02.1990-00:00:00 23
01.02.1990-06:00:00 60
01.02.1990-12:00:00 34
01.02.1990-18:00:00 56
.
.
.
.
For daily conversion I have to add four dataset for each day. How to do it in matlab?

Best Answer

T = readtable('YourFileName', 'readvariablenames', false);
daily_totals = sum(reshape(T{:,2}, 4, 1));
This assumes that there are exactly 4 entries available for each day. If that is not true, especially if there are some missing entries, then I recommend converting into timetable() object and use retime()