如何通过VBA实现位置重复性数据处理?
来源:网络收集 点击: 时间:2024-08-17在VBA中输入:
Sub位置重复性()
End Sub

在VBA中先定义可能使用的变量.
Dim i As Integer
Cells(1, 1).Value = X轴坐标
Cells(1, 2).Value = Y轴坐标
Cells(1, 3).Value = Z轴坐标
Cells(1, 4).Value = X轴坐标平均值
Cells(1, 5).Value = Y轴坐标平均值
Cells(1, 6).Value = Z轴坐标平均值
Cells(1, 7).Value = 位置重复性
Cells(1, 8).Value = 方根值
Cells(5, 4).Value = 方根值取平均
Cells(5, 5).Value = 过程值
Cells(2, 4) = 0
Cells(2, 5) = 0
Cells(2, 6) = 0
Cells(6, 4) = 0

在VBA中先进行数据的求和,再求平均值.
For j = 2 To 151 Step 5
Cells(2, 4) = Cells(j + 4, 1) + Cells(2, 4) X轴求和
Cells(2, 5) = Cells(j + 4, 2) + Cells(2, 5) Y轴求和
Cells(2, 6) = Cells(j + 4, 3) + Cells(2, 6) Z轴求和
Cells(j + 4, 1).Interior.Color = RGB(0, 255, 0)
Cells(j + 4, 2).Interior.Color = RGB(0, 255, 0)
Cells(j + 4, 3).Interior.Color = RGB(0, 255, 0)
Next
------------------------------------------------
Cells(2, 4) = Cells(2, 4) / (j - 122) X轴平均值
Cells(2, 5) = Cells(2, 5) / (j - 122) Y轴平均值
Cells(2, 6) = Cells(2, 6) / (j - 122) Z轴平均值

在VBA中求得lj的和,然后求得平均值.
For j = 2 To 151 Step 5
Cells(j + 4, 8) = ((Cells(j + 4, 1) - Cells(2, 4)) ^ 2 + (Cells(j + 4, 2) - Cells(2, 5)) ^ 2 + (Cells(j + 4, 3) - Cells(2, 6)) ^ 2) ^ 0.5 lj
Cells(6, 4) = Cells(6, 4) + Cells(j + 4, 8) lj求和
Next
Cells(6, 4) = Cells(6, 4) / 30 lj平均

在VBA中求得位置重复性.
For j = 2 To 151 Step 5
Cells(6, 5) = ((Cells(j + 4, 8) - Cells(6, 4)) ^ 2 / 29) ^ 0.5 过程值
Cells(2, 7) = Cells(6, 4) + 3 * Cells(6, 5) 位置重复性
Next

版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、文章链接:http://www.1haoku.cn/art_1129355.html