필터 지우기
필터 지우기

i have a matrix A of size 523418*2, i want to delete repeating pair?? as i explained below. any help??

조회 수: 1 (최근 30일)
a = [ 1 2 ; 2 1 ; 2 3 ; 5 2 ]
a =
1 2
2 1
2 3
5 2
i used following two logics,but neither gives my answer
>> uniqueresult = unique(sort(a,2), 'rows');
or
uniqueresult = unique(sort(a,2), 'rows','stable');
but this gives as following
uniqueresult =
1 2
2 3
2 5
but i want as
uniqueresult =
1 2
2 3
5 2

채택된 답변

Guillaume
Guillaume 2019년 2월 5일
[~, tokeep] = unique(sort(a, 2), 'rows', 'stable'); %stable optional if you don't care about the ROW ordering
result = a(tokeep, :)
  댓글 수: 2
M.Prasanna kumar
M.Prasanna kumar 2019년 2월 5일
Thank you so much sir for spending your time. I got the result
Sir, can you please explain what is [~, tokeep]
Guillaume
Guillaume 2019년 2월 5일
~ means don't care about that output (the first one). We only keep about the second output, which is the index of the unique rows (the one you want to keep).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by