I have a matrix 10x4, and I have a vector that has 10 elements. Each element is an column index of that matrix that should be retrieved. Here is the example:
This should do it for you:
M.mat[cbind(seq_along(Idx),Idx)]