■102918 / ) |
Re[1]: このエラーを解消したいです。 |
□投稿者/ みか (6回)-(2024/02/01(Thu) 21:08:59)
|
皆さん、ありがとうございます。
どこへ書いていいのか分かりませんのでここにさせて頂きます。
Next k の部分で「インデックスが配列の境界外です。」が出るのは、どこかに矛盾があるのですよね?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim y8(0 To 100) As Double
For i = 0 To 100
y8(i) = i
Next
Dim N As Integer = 5
Dim M As Integer = 2
Dim result() As Double
result = SGFilter(y8, N, M)
End Sub
Private Function SGFilter(ByVal y() As Double, ByVal N As Integer, ByVal M As Integer) As Double()
Dim i As Integer, j As Integer, k As Integer
Dim w(0 To N, 0 To M) As Double
Dim sum As Double
Dim y2() As Double
ReDim y2(0 To UBound(y))
For i = 0 To UBound(y)
sum = 0
For j = -N To N
For k = 0 To M
w(N + j, k) = ((j + k) ^ (2 * M))
Next k ' ※ インデックスが配列の境界外です。
sum = sum + w(N + j, 0)
Next j
Next i
SGFilter = y2
End Function
|
|