如下是代码:
具体算法见维基百科:https://en.wikipedia.org/wiki/Spline_interpolation
Public Function spline(x As Range, y As Range, xcontinue As Double)
Dim l1 As Integer
l1 = x.Rows.Count
Dim l2 As Integer
l2 = y.Rows.Count
If l1 <> l2 Then
spline = "Error: Range count does not match"
GoTo endnow
End If
Dim a() As Double
Dim i As Integer
Dim b() As Double
Dim n As Integer
Dim gamma() As Double
Dim ro() As Double
Dim K() As Double
Dim coef1, coef2 As Double
n = l1
ReDim a(1 To n, 1 To n)
ReDim b(1 To n)
ReDim gamma(1 To n - 1)
ReDim ro(1 To n)
ReDim K(1 To n)
'第1个点
a(1, 1) = 2 / (x(2) - x(1))
a(1, 2) = 1 / (x