title: Sum of row elements between colMin and colMax, with different colMin and colMax for each row - Octave / Matlab
body: <p>I have matrix </p>
  
  <pre><code>p=[1 2 3 4; 
     5 6 7 8; 
    10 20 30 50];
  </code></pre>
  
  <p>I'd like to compute the sum of the elements of each row that are between column iMin and iMax, with iMin and iMax being different for each row </p>
  
  <p>e.g for</p>
  
  <pre><code>iMin = [3 2 1];
  iMax = [4 4 3];
  </code></pre>
  
  <p>the result is </p>
  
  <pre><code>[7 21 60]
  </code></pre>
  
  <p>Is there an easy Octave / Matlab way to do this without loops ?</p>