title: find all the indices of all the duplicate elements in Array
body: <blockquote>
    <p>Given an Integer array, find all the indices of all the duplicate elements in it.</p>
    
    <p>For example, consider <code>A = [4, 12, 9, 8, 9, 12, 7, 1]</code>. Since 12 and 9 have duplicates, all their indices will be returned i.e. <code>d = [2, 3, 5, 6]</code>. The length of <code>A</code> is below 200 and the integer elements are between 1 and 5000.</p>
  </blockquote>
  
  <p>Currently I am using the following function. However to meet my requirements, this function is slowing me down. Is there any possible performance improvement ?</p>
  
  <pre class="lang-matlab prettyprint-override"><code>function d = fincDuplicates(A)
      U = unique(A);
      [co,ce] = hist(A,U);
      an = ce(co&gt;1);
      d=[];
      for i=1:numel(an)
          d=[d,find(A==an(i))];
      end
  end
  </code></pre>