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]
'Greg Plowman' via julia-users Sat, 19 Dec 2015 23:51:35 -0800
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]