MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
09-Jun-2016 06:01:04 73 0.01 2.3
09-Jun-2016 07:59:23 59 0.08 0.9
09-Jun-2016 08:49:10 62 0.01 2.7
09-Jun-2016 09:53:57 59 0.03 3.4

Select the last rows from each set of rows that have duplicate times. Specify the
'previous' method of retime to copy data from the last row. When you specify
'previous', then retime starts at the end of the vector of row times and stops when it
encounters a duplicate row time. Then it copies the data from that row.

TT2 = retime(TT,uniqueTimes,'previous')

TT2=5×4 timetable
Time Temp Rain WindSpeed
____________________ ____ ____ _________

09-Jun-2016 05:03:11 66.2 0.05 3
09-Jun-2016 06:01:04 73 0.01 2.3
09-Jun-2016 07:59:23 59 0.08 0.9
09-Jun-2016 08:49:10 82 0.01 2.7
09-Jun-2016 09:53:57 67 0.03 3.4

Aggregate Data from All Rows with Duplicate Times

Aggregate data from rows that have duplicate row times. For example, you can calculate
the means of several measurements of the same quantity taken at the same time.

Calculate the mean temperature, rainfall, and wind speed for rows with duplicate row
times using the retime function.

TT = retime(TT,uniqueTimes,'mean')

TT=5×4 timetable
Time Temp Rain WindSpeed
____________________ _____ ____ _________

09-Jun-2016 05:03:11 66.2 0.05 3
09-Jun-2016 06:01:04 73 0.01 2.3
09-Jun-2016 07:59:23 59 0.08 0.9
09-Jun-2016 08:49:10 71.75 0.01 2.7
09-Jun-2016 09:53:57 63 0.03 3.4

10 Timetables

Free download pdf