title: summing portions of a vector using while loop
body: <p>I am not very experienced with matlab and am struggling with while loops. I am trying to use a while loop to sum portions of a vector between zeros, and create a new vector of those sums.  Here is an example:</p>
  
  <pre><code>n=[1,3,0,5,1,2,0,4,3]
  </code></pre>
  
  <p>I want an out put vector</p>
  
  <pre><code>m=[4,8,7]
  </code></pre>
  
  <p>I have tried to even find a loop that will sum just the first section for starters but all of the while loops I have tried just run infinitely. </p>
  
  <p>e.g.</p>
  
  <pre><code>n = [1,3,0,5,1,2,0,4,3];
  
  while n &gt; 0
  
      m=sum(A)
  
  end
  </code></pre>