How to find indices of non duplicate rows in a matrix?

15 ビュー (過去 30 日間)
Luca M
Luca M 2021 年 1 月 20 日
編集済み: Luca M 2021 年 1 月 21 日
I need to find the indices of non duplicate rows in a matrix and I am not sure if there is a way to do it with:
unique()
if for example in the vector case I have:
A = [1 1 2 2 3 4 5 6 6]
I'd like to produce (as these 3 elements are unique in A):
B = [3 4 5]
by using:
A(unique_indices)
after somehow building:
unique_indices = [5 6 7]
in this case. The unique function will return a single copy of each element. Is there a quick way to do it? Thanks for tips.

採用された回答

dpb
dpb 2021 年 1 月 20 日
>> A = [1 1 2 2 3 4 5 6 6];
>> [n,b]=histc(A,unique(A));
>> A(ismember(b,find(n==1)))
ans =
3.00 4.00 5.00
>>

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNaNs についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by