regroup identical coordinate pair

1 visualización (últimos 30 días)
kix
kix el 4 de Jun. de 2020
Comentada: Star Strider el 7 de Jun. de 2020
Hi everyone,
I've got vectors like this corresponding to the coordinates of a point:
X = [1;1;8;5;5;6]
Y = [2;2;5;6;6;7]
and would like to regroup points that have the same coordinates and have the following results :
R_X = [1;8;5;6];
R_Y = [2;5;6;7];
Are there any functions or way to concatenate that would help me to do that ?
Thanks

Respuesta aceptada

Star Strider
Star Strider el 4 de Jun. de 2020
I have no idea what your objective is, however the unique function will produce the result you posted:
RX = unique(X,'stable')
RY = unique(Y,'stable')
producing:
RX =
1
8
5
6
RY =
2
5
6
7
  6 comentarios
kix
kix el 7 de Jun. de 2020
Thank you for you help !
Star Strider
Star Strider el 7 de Jun. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

Adam Danz
Adam Danz el 4 de Jun. de 2020
[~, unqIdx] = unique([X(:), Y(:)], 'rows','stable');
R_X = X(unqIdx);
R_Y = Y(unqIdx);

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by