How to identify duplicate rows in a matrix?

2 visualizaciones (últimos 30 días)
Leon
Leon el 16 de Mzo. de 2020
Editada: Leon el 16 de Mzo. de 2020
I have a matrix like the below. It could have millions of rows.
A = [Year, Month, Day, Time, Lon, Lat, A, B, C;
2005, 3, 7, 11:30am, -120, 39.5, 20, 31, 5;
...
... ];
What I want to do is to identify rows with duplicates defined as:
Time = datenum(Year, Month, Day) + Time/24;
Time1 - Time2 < (1/24/60)*30 % less than 30 mins
Lon1 - Lon2 < 0.5
Lat2 - Lat2 < 0.5
For each identified duplicate pair (e.g., Row 15 and Row 6000 are duplicates), I would hope to have two rows in a new matrix:
Year1, Month1, Day1, ... (Row #15)
Year2, Month2, Day2, ... (Row #6000)
Many thanks for any tips!

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Mzo. de 2020
Try the unique() function. After finding unique rows, then you might want to use the setdiff() function. If you still have trouble, attach a short version of your A with some duplicate rows so people can do it for you.
  1 comentario
Leon
Leon el 16 de Mzo. de 2020
Editada: Leon el 16 de Mzo. de 2020
Many thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by