I have matrix A and a vector b, which specifies column index of the element to be extracted for each corresponding row of the matrix.
For example,
A = [
As an alternative to @dantswain's solution, you can go to the linear indices directly, assuming you're always selecting from the columns:
r = size(A,1); A( (1:r).' + (b-1) * r)
This will be faster, but not necessarily clearer.
Unfortunately, there isn't an elegant solution.