title: matlab: duplicate rows removal
body: <p>I had a question and got an <a href="https://stackoverflow.com/questions/16793979/matlab-remove-duplicate-values">answer</a> yesterday about removing doubling rows in a matrix, and I can't figure out why it omits certain rows in a matrix.</p>
  
  <p>With a matrix:</p>
  
  <pre><code>tmp2 =
  
       0    1.0000
  0.1000    1.0000
  0.2000    1.0000
  0.3000    1.0000
  0.3000    2.0000
  0.4000    2.0000
  0.5000    2.0000
  0.6000    2.0000
  0.7000    2.0000
  0.7000    3.0000
  0.8000    3.0000
  0.9000    3.0000
  1.0000    3.0000
  1.1000    3.0000
  1.2000    3.0000
  </code></pre>
  
  <p>I need to remove the rows:</p>
  
  <pre><code>0.3000    2.0000    
  0.7000    3.0000
  </code></pre>
  
  <p>I tried to do it with</p>
  
  <pre><code>[~,b] = unique(tmp2(:,1));
  tmp2(b,:) 
  </code></pre>
  
  <p>I wrote something on my own</p>
  
  <pre><code>tmp3 = [];
  
  for i=1:numel(tmp2(:,1))-1
      if tmp2(i,1) == tmp3    
          tmp2(i,:) = [];
      end
      tmp3 = tmp2(i,1);
  end
  </code></pre>
  
  <p>But all of the methods seem to omit the first row to remove... Please help, as I already spent some hours trying to fix it myself (I suck at programming...) and nothings seems to work. The matrix is an example, but generally if two rows have the same value in the first column I have to remove the second one</p>