| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 840 人关注过本帖
标题:刚接触VB一天,代码求助
只看楼主 加入收藏
kingjames
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-5-16
收藏
 问题点数:0 回复次数:0 
刚接触VB一天,代码求助
刚接触VB一天,代码求助
一直用的是matlab,由于一个代码不会用matlab编程  故找大神借用了vb代码
求助:如何在vb6.0运行代码   数据如何输入运行
问题比较垃圾  还请大神不吝赐教(毕业论文需要,无奈呀)

代码如下:
Public Function Yamamoto(data() As Double, SNR() As String, a As Double)  'Yamaoto 突变性检验(检验突变点)
''Data 存储两列数据,第一列时间数据,第二列观测数据
'SNR 存储两列数据,第一列时间数据,第二列观测数据
Dim m1 As Long, m2 As Long
Dim n1 As Long, n2 As Long
Dim i As Long, j As Long
Dim Ex1 As Double, Ex2 As Double
Dim Std1 As Double, Std2 As Double
Dim max As Double, max_num As Long
On Error GoTo Yamo:
m1 = LBound(data, 1)
n1 = UBound(data, 1)
m2 = LBound(data, 2)
n2 = UBound(data, 2)
ReDim SNR(m1 To n1 - 3, m2 To n2)
i = m1 + 1
Do While (i < n1 - 1)
Ex1 = 0
Std1 = 0
For j = m1 To i
Ex1 = Ex1 + data(j, n2)
Std1 = Std1 + data(j, n2) * data(j, n2)
Next
Ex1 = Ex1 / (i - m1 + 1)
Std1 = Sqr(Std1 / (i - m1) - Ex1 * Ex1)
Ex2 = 0
Std2 = 0
For j = i + 1 To n1
Ex2 = Ex2 + data(j, n2)
Std2 = Std2 + data(j, n2) * data(j, n2)
Next
Ex2 = Ex2 / (n1 - i)
Std2 = Sqr(Std2 / (n1 - i - 1) - Ex2 * Ex2)
SNR(i - 1, m2) = data(i, m2)
SNR(i - 1, n2) = Abs(Ex1 - Ex2) / (Std1 + Std2)
If i = m1 + 9 Then
max = SNR(i - 1, n2)
Yamamoto = SNR(i - 1, m2)
If (n1 - i) > (i - m1 + 1) Then
max_num = i - m1 + 1
Else
max_num = n1 - i
End If
ElseIf (n1 - i) > 9 And (i > m1 + 9) Then
If max < SNR(i - 1, n2) Then
max = SNR(i - 1, n2)
Yamamoto = SNR(i - 1, m2)
If (n1 - i) > (i - m1 + 1) Then
max_num = i - m1 + 1
Else
max_num = n1 - i
End If
End If
End If
i = i + 1
Loop
If max > Hydrological_S.T_INV(n1 - m1 - 1, 1 - a / 2) / Sqr(max_num) Then
Yamamoto = "The change point is :" & Yamamoto & " with signficance(suggested)"
Exit Function
Else
Yamamoto = "The change point is :" & Yamamoto & " with no signficance(suggested)"
Exit Function
End If
Yamo:
 Yamamoto = "Error:"
End Function
搜索更多相关主题的帖子: 代码 数据 data Double If 
2018-05-16 15:31
快速回复:刚接触VB一天,代码求助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017029 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved