Converting to linear indexes seems to be a legal way:
indices = tuples(:, 1) + size(a,1)*(tuples(:,2)-1); selection = a(indices);
Note that this is also implemented in the Matlab sub2ind built-in solution, as in nate'2's answer:
a(sub2ind(size(a), tuples(:,1),tuples(:,2)))
but
a = rand(50); tuples = [1,1; 1,4; 2,5]; start = tic; for ii = 1:1e4 indices = tuples(:,1) + size(a,1)*(tuples(:,2)-1); end time1 = toc(start); start = tic; for ii = 1:1e4 sub2ind(size(a),tuples(:,1),tuples(:,2)); end time2 = toc(start); round(time2/time1)
which gives
ans = 38
therefore, although sub2ind easier on the eyes, it is also ~ 40 times slower. If you need to perform this operation frequently, select the method above. Otherwise, use sub2ind to improve readability.
source share