title: How to accumulate data-sets?
body: <p>I have vector with values between <code>1</code> and <code>N &gt; 1</code>. Some values COULD occur multiple times consecutively. Now I want to have a second row which counts the consecutively entries and remove all those consecutively occuring entries, e.g.:</p>
  
  <pre><code>A = [1 2 1 1 3 2 4 4 1 1 1 2]'
  </code></pre>
  
  <p>would lead to:</p>
  
  <pre><code>B = [1 1;
       2 1;
       1 2;
       3 1;
       2 1;
       4 2;
       1 3;
       2 1]
  </code></pre>
  
  <p>(you see, the second column contains the number of consecutively entries!
  I came across <code>accumarray()</code> in MATLAB recently but I can't find any solution with it for this task since it always regards the whole vector and not only consecutively entries.</p>
  
  <p>Any idea?</p>