How to find vector indexes without for loops?

I'm trying to speed up my code, which essentially computes distances of 9 million points to 72k points and looks up values based on that distance.

I have one large mesh array (3,000 x 3,000 feet in X/Y coord.) which I can step through element by element. For each element, I need to compute the distance to 72001 points (xpos_vector and ypos_vector). I then round that distance and use a lookup table to get pre-computed values.

I tried looping 72001 times within the i/j loops, but that is taking an enormous amount of time. I was hoping to "vectorize" the distances, but the issue is that the find function won't allow me to find which index each element of the vector corresponds to, only the few indexes which happen to match perfectly.

I have on 72001 element vector and I need to return a 72001 element vector of indexes based on a lookup vector (of different size.) Is there any way to do this without a for loop? I.E. - it would be perfect if index=find(vector.==lookup) would run and return an array of size(vector).

ok well I've come a bit further, but now I'm stuck trying to figure out how to feed an array of indexes (72001 elements) to a smaller array (4500 elements) and return a larger array (72001 elements) of values corresponding to the indexes.

Without using an additional for-loop, I need to pass in an arbitrary number of indexes to a lookup array and return an array of the arbitrary size.

It's also a bit confusing that you're looping over 100 different i,j pairs if round_distance is only 100x1.

I'm stuck trying to figure out how to feed an array of indexes (72001 elements) to a smaller array (4500 elements) and return a larger array (72001 elements) of values corresponding to the indexes.

The size of the indices versus the lookup data doesn't seem like it should really be the confounding issue. It is generally true in MATLAB that the output of an indexing operation will always be the same size of the indexing data and independent of the size of the lookup data. A trivially example with 1x1 lookup data would be