Blending/Interpolating between array values

Hi, guys, still pretty new to the whole Arduino and Programming thing, so anyways for some background:

I've got a mass-air-flow sensor, which puts out a 0-5v signal depending on the rate of air flowing through it. It has a very non-linear response, requiring the use of an array to convert the voltage to kg/Hr flow. I've setup it like so:

``````int maft[20]={3,11,20,45,83,113,190,280,380,520,750,960,1230,1600,1900,2500,3000,3600,4200,5000};
mafv = map(analogRead(1),0, 1023, 0, 19);
maff = maft[mafv]; //creates the kg/hr number for later functions to use for calculations
``````

It works well enough, but towards the high end you get very abrupt transitions. So I was wondering how I'd go about creating a function that allows "maff" to blend between two adjacent maft values, preferably in a weighted manner? Ex: If the remapped adc value was "18.5", it'd simply average 4200 and 5000 together. If the value were 18.75, it'd blend 75% of 5000 with 25% of 4200. (I know the map function only generates whole integers, just trying to show an example of what I'm trying to do)

If you aren't in a hurry you could use floating-ppoin math:

``````    float entry = (analogRead(1) * 19 ) / 1024.0;  // Value from 0 to 18.999
float fraction = entry - (int) entry;  // Subtract out the integer part
float value =  maft[(int)entry] + (maft[(int)entry+1] - maft[(int)entry]) * fraction;
``````