regroup identical coordinate pair
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Star Strider
2020년 6월 4일
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
추가 답변 (1개)
Adam Danz
2020년 6월 4일
[~, unqIdx] = unique([X(:), Y(:)], 'rows','stable');
R_X = X(unqIdx);
R_Y = Y(unqIdx);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!