Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Paul
Posts:
492
Registered:
2/23/10


Efficient general purpose 1D lookup table?
Posted:
Dec 5, 2013 10:12 PM


I have a set of unique integers that map to another set of unique integers. Neither set is necessarily contiguous or monotonic. I would like to implement this as a translation/lookup table. Googling lookup and matlab yields many means of interpolating, but that's not the context I'm working in. I can use ismember to create a translation table, but that uses the index of one array as the value to be translated. It allows me to vectorize the translation of a series of input values, but since the possible input values are not necessarilly contiguous, using the array index does not seem elegant.
Of course, I can write a function that accepts a lookup table in the form of a Nx2 array and simultaneously accepts a vector of input values to translate. My function would loop through each input value, look them up, and return the results (collected into a vector). I was hoping there was a readytouse vectorizable way to do this.



