-2

I have an array A as follows:

A = [7 7 10 10 10 15 1 1 15 15 7 16 17 1 18]. ';

How can I obtain all numbers which occur more than one times in my array? In this example the answer should be 1 7 10 15.

Adupa Vasista
  • 71
  • 1
  • 12

2 Answers2

2

Here's another approach, just for variety:

[~, ind] = unique(A);
result = A;
result(ind) = [];
result = unique(result);
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
0

Solved it by using the following code

[ii,jj,kk]=unique(A);
repeated=ii(histc(kk,1:numel(ii))>1);
Adupa Vasista
  • 71
  • 1
  • 12