MATLAB: How to find the indices of element occuring once in a vector

indices

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

Best Answer

There are ways to solve your problem based on HISTC or ACCUMARRAY. However, the simplest approach if you really have only two situations (unique 1 or unique -1) is probably the following:
if sum( A == 1 ) == 1
pos = find( A == 1 ) ;
else
pos = find( A == -1 ) ;
end
value = A(pos) ;