title: Create a vector that holds the index of all the columns which has non-zero values based on a condition
body: <p>I have a matrix filled with zeros and ones and I need to count the number of ones in each row. Then I need to know which row's count exceeds or equal a specific limit (any number, for example 3). After that foreach row in these rows I need to create a vector that holds the index of all the columns which has non-zero values in that row and in all the rows above it and below it till it reach a row with zero count.</p>
  
  <p>Example:
  data contains the data below:</p>
  
  <pre><code>0 0 0 0 0 0 0
  0 0 0 1 1 0 0
  0 1 0 0 1 0 1
  0 0 0 0 0 0 0
  0 1 0 0 0 0 0 
  0 1 1 1 0 0 0
  0 0 1 0 0 0 0
  0 0 0 0 0 0 0
  </code></pre>
  
  <p>The output should be if the limit is 3:</p>
  
  <pre><code>Row 3: col 4 5 2 5 7 
  Row 6: col 2 2 3 4 3 
  </code></pre>
  
  <p>I already read the data and I counted the ones in the code below:</p>
  
  <pre><code>load('data');
  mat(isnan(mat)) = 0;
  [rows,cols,vals]  = find(mat~= 0);
  unqRows=unique(rows);
  countElinRows=histc(rows,unqRows);
  </code></pre>
  
  <hr>
  
  <p><strong>Edit for clarification as requested by commentators:</strong></p>
  
  <p>If the third row of the given sample input array becomes <code>[0 1 0 0 0 0 1]</code>, then we must only have this output - </p>
  
  <pre><code>Row 6: col 2 2 3 4 3
  </code></pre>