How can i find an eleiment which comes only one in a matrix ?????

1 回表示 (過去 30 日間)
raj singh
raj singh 2016 年 6 月 22 日
回答済み: Jos (10584) 2016 年 6 月 24 日
Example
A=[1 2;1 3;1 4;1 5;2 4]
Ans should be [3 5]

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 6 月 22 日
編集済み: Azzi Abdelmalek 2016 年 6 月 22 日
A=[1 2;1 3;1 4;1 5;2 4]
[ii,jj,kk]=unique(A)
b=accumarray(kk,(1:numel(kk))',[],@numel)
out=ii(b==1)

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2016 年 6 月 24 日
When A only contains positive integers:
A = [1 2 3 1 2 4 1 2 4 5]
B = find(sparse(A(:),1,1)==1)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by