title: MATLAB: Adding vectors to a matrix and counting the number of non zeros
body: <p>I have the following problem:</p>
  
  <pre><code>A = [] % matrix
  Q = [] % number on non zero in each row 
  
  for i=1:10  
  % I generate a path with name path 
  % add the path to the matrix A  
  end
  % count number on non zero numbers in each row 
  </code></pre>
  
  <p>How can I do that? </p>
  
  <p>Here is an illustrative example: </p>
  
  <ol>
  <li>If the path in first iteration was: <code>path = [ 1 2 3 4 ]</code></li>
  <li>In the second iteration: <code>path = [ 4 5 6 ]</code></li>
  <li>In third iteration: <code>path = [ 7 2 ]</code></li>
  </ol>
  
  <p>Then A should be like this:</p>
  
  <pre><code> A = 
     [1 2 3 4 ,
      4 5 6 0 ,
      7 2 0 0 ] 
  </code></pre>
  
  <p>After, I would like a vector to show me the number of numbers different than zero in each row like so:</p>
  
  <pre><code>Q = [4 3 2] 
  </code></pre>