dupTimes = sort(TT.Time);
TF = (diff(dupTimes) == 0);
dupTimes = dupTimes(TF);
dupTimes = unique(dupTimes)
dupTimes = 2x1 datetime array
09-Jun-2016 08:49:10
09-Jun-2016 09:53:57
Index into the timetable to display the rows with duplicate row times. When you index on
times, the output timetable contains all rows with matching row times.
TT(dupTimes,:)
ans=6×4 timetable
Time Temp Rain WindSpeed
09-Jun-2016 08:49:10 62 0.01 2.7
09-Jun-2016 08:49:10 67.2 0.01 2.7
09-Jun-2016 08:49:10 75.8 0.01 2.7
09-Jun-2016 08:49:10 82 0.01 2.7
09-Jun-2016 09:53:57 59 0.03 3.4
09-Jun-2016 09:53:57 67 0.03 3.4
Select First and Last Rows with Duplicate Times
Select either the first and the last of the rows with duplicate row times using the unique
and retime functions.
First, create a vector of unique row times from TT using the unique function.
uniqueTimes = unique(TT.Time);
Select the first row from each set of rows that have duplicate times.
TT2 = retime(TT,uniqueTimes)
TT2=5×4 timetable
Time Temp Rain WindSpeed
09-Jun-2016 05:03:11 66.2 0.05 3
Clean Timetable with Missing, Duplicate, or Nonuniform Times