title: Get first two maximum values in matrix
body: <p>I've got a matrix (n x m). And I'd like to know, for each row, the indexes of the coloums that contain the first two maximum values:</p>
  
  <pre><code>2 3 4 2
  2 4 7 1
  1 1 2 4
  5 5 9 6
  1 4 2 1
  9 8 1 2
  </code></pre>
  
  <p>The answer should be:</p>
  
  <pre><code>2 3
  2 3
  3 4
  3 4
  2 3
  1 2
  </code></pre>
  
  <p>How can I obtain it with matlab commands? I'd like not to use for loops. I tried with:</p>
  
  <pre><code>[x,y]=max(matrix')
  y=y';
  </code></pre>
  
  <p>y gives me the colum indexes for the maximum elements. Now I'd set to zero these elements and repeat the instructions but I have no idea how to do. I treid:</p>
  
  <pre><code>matrix(:,y)=0;
  </code></pre>
  
  <p>but it doesn't work.</p>