VBA:抛物线拟合~

利用VBA进行抛物线拟合,采用最小二乘法进行数据处理,展示VBA在数值分析中的应用。
摘要由CSDN通过智能技术生成

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 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值