How to interpolate the inverse of a table?


#1

Is there an object that can be used as the functional inverse of "table/read interp"?

I'm creating a calibration program for a ribbon controller that has to sync my finger with a strip of one-cm spaced LED's, and I have a table that can take the number of centimeters your finger is on the ribbon and turn it into a voltage (I pressed my finger down every cm on the ribbon and recorded the voltages in a table). But I need to take the inverse of this function, to convert voltage to centimeters (on the ribbon), which is obviously more useful :stuck_out_tongue:

Is there an object that I can use to do this? (The fact that my table is monotonically increasing ensures that an inverse exists for this table: so it might look like [1,2,3,6,8] but will never look like [1,1,2,2,3,3] or [5,3,2,6,8] etc.)


#2

afaik, there is no object to do this (there isn't in the factory, you never know in the community library)

you could write one, basically you need to do a binary search on a table (as its sorted) for the value, this is ok, as long as the able is small... but you will hit performance issues if it becomes large.

however, id be tempted to try to do this by determining the mathematical relationship between position and voltage... this would take less resources (memory and cpu)
depending on your ribbon, its probably exponential, plus a bit of scaling/offset.
if you plotted the values on a spreadsheet, it would probably be easy enough to find a close approximation... without that it would be a bit of trial n error.


#3

Aww, thats dissapointing - I've got the theoretical relationship down, it's just not perfect: the ribbon isn't precisely linear as it should be. It's very close to linear but not quite there; even a third-order polynomial fit doesn't work very well :stuck_out_tongue: But thanks for the response!