Given an n-dimensional matrix of values: what is the most efficient way of retrieving values by arbitrary indices (i.e. coordinates)?
E.g. in a random 5x5 matrix, if I want the values at (1,1) (2,3) and (4,5) what is the most efficient way of returning just the values at these coordinates?
If I provide these coordinates in a separate matrix for example is there a one line of MATLAB which can do the job? Something like:
x=rand(5,5);
y=[[1,1];[2,3];[4,5]];
z=x(y);
Except that doesn't work.
One caveat however, for various reasons I am unable to use linear indexing - the results must be returned using the original indices. And the size of these matrices is potentially very large so I don't want to use loops either.