title: matrix containing number of occurrence corresponding to each element in the matrix
body: <p>I have matrix, suppose </p>
  
  <pre><code>A = [1 2 3 1 1 1 2 3]
  </code></pre>
  
  <p>I want to find number of times the number appeared in the matrix. The output matrix for this i/p would be </p>
  
  <pre><code>B = [1 1 1 2 3 4 2 2]
  </code></pre>
  
  <p>i.e. 1 appeared 4 times in the array, hence last value corresponding to 1 is 4.</p>
  
  <p><code>unique</code> and <code>sum unique</code> do not help because it gives total number of times the element occured, but I want another matrix which increases the count every time it occurs.</p>