Remove the duplicated vector in the array
이전 댓글 표시
Hi. I'm struggling with how to make my code.
Here is the thing. I want to get a new matrix A such that all duplicated vectors are removed. Here is my matrix A and a new matrix A that I want to get:
A = [1 3; 1 4; 1 3; 1 4; 2 3; 3 4; 3 4; 3 5; 4 5]
new A = [1 3; 1 4; 2 3; 3 4; 3 5; 4 5].
How to write the code to get new A...? I'm trying to make it as a function, however, I don't have clear ideas...
I need some help! Thank you so much!!
채택된 답변
추가 답변 (1개)
nandishwar
2026년 7월 28일 8:23
0 개 추천
function new_A = remove_duplicate_rows(A)
% REMOVE_DUPLICATE_ROWS Removes duplicate row vectors from matrix A.
% 'rows' treats each row as a single vector.
% 'stable' keeps the original order of the remaining unique rows.
new_A = unique(A, 'rows', 'stable');
end
카테고리
도움말 센터 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!