How can I strip duplicates?

1 visualización (últimos 30 días)
Holm Roeser
Holm Roeser el 8 de Abr. de 2021
Editada: per isakson el 13 de Oct. de 2021
I wish to remove all duplicate rows based off of the first column. That is, I want to just strip the excess away. I am struggling to understand how to implement "unique" here. Thanks in advance
  5 comentarios
Cris LaPierre
Cris LaPierre el 9 de Abr. de 2021
Ah, got it. Thanks.
per isakson
per isakson el 13 de Oct. de 2021
Editada: per isakson el 13 de Oct. de 2021
The values in the first column are not whole numbers. Thus uniquetol is appropriate.

Iniciar sesión para comentar.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 9 de Abr. de 2021
If you want
  1. remove duplicates only based on values in the first column
  2. Do not want the returned values be sorted
then you need to do this
in=[[5;5;5;4;4;4;3;3;3;1],(1:10)'];
[~, index]=unique(in(:,1),'stable');
out=in(index,:)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by