VBA写的抛物线拟合~ 最小二乘法~
请各位大牛指正~
Public Function SecFit(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
Dim n As Integer
If l1 <> l2 Then
spline = "Error: Range count does not match"
GoTo endnow
Else
n = l1
End If
Dim t0 As Double
Dim t1 As Double
Dim t2 As Double
Dim t3 As Double
Dim t4 As Double
Dim sy As Double
Dim syx As Double
Dim syxx As Double
t0 = 0
t1 = 0
t2 = 0
t3 = 0
t4 = 0
sy = 0
syx = 0
syxx = 0
For i = 1 To n
t0 = t0 + 1
t1 = t1 + x(i)
t2 = t2 + x(i) * x(i)
t3 = t3 + x(i) * x(i) * x(i)
t4