MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
01:58:19
00:49:47
00:00:00
00:00:00
00:00:00
01:04:47
00:00:00
00:00:00

Remove Duplicate Rows

Timetables can have duplicate rows. Timetable rows are duplicates if they have the same
row times and the same data values. In this example, the last two rows of TT are
duplicates.

To remove the duplicate rows, use the unique function. unique returns the unique rows
and sorts them by their row times.

TT = unique(TT)

TT=9×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 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

Find Rows with Duplicate Times and Different Data

Timetables can have rows with duplicate row times but different data values. In this
example, TT has several rows with the same row times but different values.

Find the rows that have duplicate row times. First, sort the row times and find
consecutive times that have no difference between them. Times with no difference
between them are the duplicates. Index back into the vector of row times and return a
unique set of times that identify the duplicate row times in TT.

10 Timetables

Free download pdf