How to find the indices of element occuring once in a vector?
古いコメントを表示
Hello all
I want to know...How can I get the indices of a value that is occuring only once in a vector...please guide.
Example: A=[1 1 0 -1 0 0 1 0 1 1]
Task: To identify the indices of -1 (as it is occuring only once) in A.
Please Help!!!
Regards
採用された回答
その他の回答 (3 件)
George Papazafeiropoulos
2014 年 5 月 23 日
編集済み: George Papazafeiropoulos
2014 年 5 月 23 日
A=[1 1 0 -1 0 0 1 0 1 1];
[~,c]=histc(A,unique(A));
out=A(c==1);
Mahdi
2014 年 5 月 23 日
If you're looking specifically for the value of -1, you can use the following:
index1=find(A==-1)
George Papazafeiropoulos
2014 年 5 月 23 日
編集済み: George Papazafeiropoulos
2014 年 5 月 23 日
A=[1 1 -1 0 0 0 1 0 1 1];
[~,c]=histc(A,unique(A));
out=find(c==1);
3 件のコメント
Sameer
2014 年 5 月 23 日
George Papazafeiropoulos
2014 年 5 月 23 日
Try the above code for different A. Define A as you want and then execute the two last lines of the code. I think it works...
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
