VB写的最小二乘法曲线拟合.doc

  1. 1、本文档共8页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
VB写的最小二乘法曲线拟合

Option Explicit Dim x() As Double, y() As Double Dim A(20, 20) As Double, M As Double, B() As Double 最多取20次的拟合 Dim N As Double, I As Double, j As Double Dim xiaoA() As Double Dim Xmin As Double, Xmax As Double Dim Ymin As Double, Ymax As Double Dim X0pos As Double, Y0pos As Double Dim xmaxpos As Double, ymaxpos As Double Dim xstep As Double, ystep As Double Dim xl As Double, yl As Double Dim xbc As Double, ybc As Double Dim bc As Double Dim Xh As Double Private Sub HuaZuoBiao(x() As Double, y() As Double) ReDim xpos(I) As Double ReDim ypos(I) As Double ReDim x(I), y(I) X0pos = Width * 0.25 坐标原点最左点 Y0pos = Height * 0.75 坐标原点最低点 xmaxpos = Width * 0.85 坐标最右点 ymaxpos = Height * 0.15 坐标最高点 xstep = (xmaxpos - X0pos) / (Xmax - Xmin) 对应X轴上单位长度代表的屏幕宽度值 ystep = (ymaxpos - Y0pos) / (Ymax - Ymin) 对应Y轴上单位长度代表的屏幕高度值 在屏幕上画直角坐标系 ForeColor = vbBlue Line (Width * 0.1, Y0pos)-(Width * 0.9, Y0pos) 画X坐标轴,从左10%,到右的90%处 Line (X0pos, Height * 0.1)-(X0pos, Height * 0.9) 画y坐标轴,从上10%,到下的90%处 Font.Size = 20 指定X轴,Y轴标志的字体大小 CurrentX = Width * 0.9 CurrentY = Y0pos + 100 Print X 在横线上画X轴标志 在横线上画X轴箭头标志 CurrentX = Width * 0.9 CurrentY = Y0pos Line (CurrentX - 200, CurrentY - 50)-(CurrentX, CurrentY) Line (CurrentX, CurrentY)-(CurrentX - 200, CurrentY + 50) CurrentX = X0pos - 500 CurrentY = Height * 0.1 Print y 在纵线上画Y轴标志 在纵线上画Y轴箭头标志 CurrentX = X0pos CurrentY = Height * 0.1 Line (CurrentX - 50, CurrentY + 200)-(CurrentX, CurrentY) Line (CurrentX, CurrentY)-(CurrentX + 50, CurrentY + 200) CurrentX = X0pos + 200 此为Y轴左边500绝对坐标处 CurrentY = Y0pos + 400 取当前Y轴上的相对坐标值 Print f=f(x) 在Y轴左边500绝对坐标处对应显示Y轴相对坐标刻度值 xl = Xmax - Xmin yl = Ymax - Ymin If xl 0.01 Then xbc = 0.001 ElseIf xl = 0.1 Then xbc = 0.01 ElseIf xl = 2 Then xbc = 0.1 ElseIf xl = 20 Then xbc = 1 ElseIf xl = 120 Then xbc = 10 ElseIf xl = 1000 Then xbc = 100 ElseIf xl = 10000 Then xbc = 1000 Else xbc = 10000 End If If yl 0.01 Then ybc = 0.001 ElseIf yl = 0.1 Then ybc = 0.01 ElseIf yl = 2 Then ybc = 0.1 E

文档评论(0)

zilaiye + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档