title: Index a vector by a matrix of conditions to obtain multiple selections of the target?
body: <p>I have a vector <code>T</code> of length <code>n</code> and <code>m</code> other vectors of the same length with <code>0</code> or <code>1</code> used as condition to select elements of <code>T</code>. The condition vectors are combined into a matrix <code>I</code> of size <code>n x m</code>.</p>
  
  <p>Is there a one liner to extract a matrix <code>M</code> of values from <code>T</code>such that the i-th column of <code>M</code> are those elements in <code>T</code> that are selected by the condition elements of the i-th column in <code>I</code>?</p>
  
  <p>Example:</p>
  
  <pre><code>T = (1:10)'
  I = mod(T,2) == 0
  T(I)'
  </code></pre>
  
  <p>yields</p>
  
  <pre><code>2    4    6    8   10
  </code></pre>
  
  <p>However</p>
  
  <pre><code>I = mod(T,2:4) == 0
  T(I)'
  </code></pre>
  
  <p>yields an error in the last statement. I see that the columns might select a different number of elements which results in vectors of different lengths (as in the example). However, even this example doesn't work:</p>
  
  <pre><code>I = zeros(10,2)
  I(:,1) = mod(T,2)==0
  I(:,2) = mod(T,2)==1
  </code></pre>
  
  <p>Is there any way to achieve the solution in a one liner?</p>