title: Extract elements given 2D matrix of column indices per row from a 2D matrix in MATLAB
body: <p>I tried to resample my data from a block of matrix that defined its indices. Hopefully this example can make it clear:</p>
  
  <pre><code>A=rand(18400,100);
  A_IDX=randi([1 100],[18400 100]);
  </code></pre>
  
  <p><code>A_IDX</code> consist 18400 rows and 100 columns. I wanted to extract the matrix <code>A</code> at the <code>A_IDX</code> indices. Result would be something like:</p>
  
  <pre><code>A=[1 2 3; 4 5 6];
  A_IDX=[1 3; 2 3];
  A_Result=[1 3; 5 6];
  </code></pre>
  
  <p>I tried <code>A(:,A_IDX)</code> but that gave me 1840x184000 matrix size, which is not what I wanted to do in the first place. Anyone can help? Thanks in advance!</p>