supp:excel_for_scientists:interpolation
This is an old revision of the document!
Interpolation
Linear
Option Explicit
Function InterpolateL(lookup_value, known_xs, known_ys)
Dim pointer As Integer
Dim X0 As Double
Dim Y0 As Double
Dim X1 As Double
Dim Y1 As Double
'Following line added to prevent extrapolation
If lookup_value < Application.Min(known_xs) Or lookup_value > Application.Max(known_xs) Then
InterpolateL = CVErr(xlErrRef): Exit Function
End If
pointer = Application.Match(lookup_value, known_xs, 1)
X0 = known_xs(pointer)
Y0 = known_ys(pointer)
X1 = known_xs(pointer + 1)
Y1 = known_ys(pointer + 1)
InterpolateL = Y0 + (lookup_value - X0) * (Y1 - Y0) / (X1 - X0)
End Function
supp/excel_for_scientists/interpolation.1448535516.txt.gz · Last modified: 2015/11/26 10:58 by admin
