arraysmatlabfind-occurrences

Find repeated elements occuring more than Once


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.


Solution

  • Solved it by using the following code

    [ii,jj,kk]=unique(A);
    repeated=ii(histc(kk,1:numel(ii))>1);