d = [3, 0, 0, 1, 1, 0, 5, 3]; unique(d(sum(triu(bsxfun(@eq,d,d')))>1))
Standard input is empty
ans = 0 1 3
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!