Possible Duplicate:
MATLAB indexing question
How to extract non-vertical column from matrix in Matlab
I feel like there should be a simple way to do what I want, but I cannot figure this out.
INPUT: an n x t matrix M of reals and an n x 1 vector I of indices
OUTPUT: an n x 1 vector P such that P(i) = M( i, I(i) )
It's obvious how to do this with a for loop, but this is Matlab and n is large. Is there a way to vectorize this problem and avoid the for loop?