title: Vectorizing the Notion of Colon (:) - values between two vectors in MATLAB
body: <p>I have two vectors, <code>idx1</code> and <code>idx2</code>, and I want to obtain the values between them. If <code>idx1</code> and <code>idx2</code> were numbers and not vectors, I could do that the following way:</p>
  
  <pre><code>idx1=1;
  idx2=5;
  values=idx1:idx2 
  
  % Result
   % values =
   % 
   %    1     2     3     4     5
  </code></pre>
  
  <p>But in my case, <code>idx1</code> and <code>idx2</code> are vectors of variable length. For example, for length=2:</p>
  
  <pre><code>idx1=[5,9];
  idx2=[9 11];
  </code></pre>
  
  <p>Can I use the colon operator to directly obtain the values in between? This is, something similar to the following:</p>
  
  <pre><code>values = [5     6     7     8     9     9    10    11]
  </code></pre>
  
  <p>I know I can do <code>idx1(1):idx2(1)</code> and <code>idx1(2):idx2(2)</code>, this is, extract the values for each column separately, so if there is no other solution, I can do this with a for-loop, but maybe Matlab can do this more easily.</p>