The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Efficient general purpose 1D lookup table?
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  

Posts: 517
Registered: 2/23/10
Efficient general purpose 1D lookup table?
Posted: Dec 5, 2013 10:16 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Sorry if this shows twice. I am getting repeated messages about errors getting this posting, even from different computers on different networks.

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 ready-to-use vectorizable way to do this.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.