regroup identical coordinate pair
Show older comments
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
Accepted Answer
More Answers (1)
Adam Danz
on 4 Jun 2020
[~, unqIdx] = unique([X(:), Y(:)], 'rows','stable');
R_X = X(unqIdx);
R_Y = Y(unqIdx);
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!