필터 지우기
필터 지우기

How to find unique rows with unordered elements?

조회 수: 6 (최근 30일)
Oliver
Oliver 2014년 1월 13일
편집: Azzi Abdelmalek 2014년 1월 13일
Say I have the following matrix:
>> A = [1 2 3; 2 4 6; 3 1 2; 1 1 1]
A =
1 2 3
2 4 6
3 1 2
1 1 1
How can I identify the unique rows where I don't care what order the row elements are in? For example, in this case row 1 is equivalent to row 3 because both contain the elements 1, 2, and 3, the only difference is their order. So the unique rows would be A([1,2,4],:).

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 13일
편집: Azzi Abdelmalek 2014년 1월 13일
A = [1 2 3; 2 4 6; 3 1 2; 1 1 1]
[idx,idx]=unique(sort(A')','rows','stable');
B=A(idx,:)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by