title: Matlab: Find row indice of first occurrence for each column of matrix (without using loops)
body: <p>For each column of a matrix A consisting of '0' and '1', I would like to find the column indices of the first occurrence of '1' if exists. For example, if A is defined as:</p>
  
  <pre><code> A=[0 0 0 0;
   0 0 0 1;
   0 0 0 0;
   0 0 0 1;
   1 0 0 0;
   0 1 0 1;
   1 1 0 0]
  </code></pre>
  
  <p>then the result would be:</p>
  
  <pre><code>b=[5 6 2]
  </code></pre>
  
  <p>I'm searching for a solution without any 'for' or 'while' loops.</p>
  
  <p>One solution I came up with:</p>
  
  <pre><code> [b,~]=find(cumsum(cumsum(A))==1)
  </code></pre>
  
  <p>Is there a more elegant way to do this?</p>