I'm guessing you want y to specify a column from each row.
Not sure how to do this directly. Closest I can think of this:

a = [ -1 2; 3 -4 ] 
y = [ 1, 2 ]
i = sub2ind(size(a), 1:2, y)
a[i]

Reply via email to