G
Guest
Does anyone have a good UDF for linear interpolation?
I want something like
Linterp(KnownXs, KnownYs, NewX)
It will find and use the two points surrounding NewX and linearly
interpolate the Y-value. If NewX is beyond the range of KnownXs, then it
will use either the first or last two to extrapolate an answer.
Please note, I am not asking you to make one for me, I would assume that
many people have already made one for themselves. Also I am not interested
in the LINEST, FORECAST, or TREND functions. They are not the same as linear
interpolation. I know you can use FORECAST if you have the two points you
want to use, but I would like to be able to pick the entire list of X's and
Y's.
I want something like
Linterp(KnownXs, KnownYs, NewX)
It will find and use the two points surrounding NewX and linearly
interpolate the Y-value. If NewX is beyond the range of KnownXs, then it
will use either the first or last two to extrapolate an answer.
Please note, I am not asking you to make one for me, I would assume that
many people have already made one for themselves. Also I am not interested
in the LINEST, FORECAST, or TREND functions. They are not the same as linear
interpolation. I know you can use FORECAST if you have the two points you
want to use, but I would like to be able to pick the entire list of X's and
Y's.