Remove all elements that occur more than once in a vector
Show older comments
Hello, I need to take a vector and remove any element that is repeated. I have tried unique(vector) but that only makes sure that each element is not repeated. I've considered comparing a number with the rest of the vector, but I can't come up with a way to do that generically. Could anyone point me in the right direction?
Accepted Answer
More Answers (1)
Walter Roberson
on 30 Jan 2019
uA = unique(A);
uA(histcounts(A,[uA,inf])==1)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!