VBA中数组的问题 20
我有下面一段程序,但是里面有关的数组的赋值不是很看的懂,这里的UAlt是一个定义为5个元素的一维数组吧,那后面的UAlt(0)是表示第一个数么?当l=0M=0时,一切正确...
我有下面一段程序,但是里面有关的数组的赋值不是很看的懂,这里的UAlt是一个定义为5个元素的一维数组吧,那后面的UAlt(0)是表示第一个数么? 当l=0M = 0时,一切正确.但M>0时我就不明白了,怎么就得到U(n-i)?
这里di就是FiltKoeff(M, 1).
Public Sub DigFilt(ByRef UinVec() As Double, ByRef UoutVec() As Double, ByRef FiltKoeff() As Double, Spalte As Integer)
Dim l As Integer
Dim M As Integer
ReDim YAlt(0 To 4)
ReDim UAlt(0 To 4)
Dim val As Double
Dim Anz As Long
Anz = UBound(UinVec, 1) - LBound(UinVec, 1) + 1
For l = 0 To Anz - 1
UAlt(0) = UinVec(l, Spalte) 'Neuer Wert U(n) am Eingang
val = 0
For M = 0 To 4
val = val + FiltKoeff(M, 1) * UAlt(M) 'summiere alle di*U(n-i)
Next M
For M = 1 To 4
val = val - FiltKoeff(M, 0) * YAlt(M) 'subtrahiere alle ci*Y(n-i)
Next M
YAlt(0) = val
For M = 0 To 3
UAlt(4 - M) = UAlt(4 - M - 1)
YAlt(4 - M) = YAlt(4 - M - 1)
Next M
UoutVec(l, Spalte) = val
Next l
End Sub 展开
这里di就是FiltKoeff(M, 1).
Public Sub DigFilt(ByRef UinVec() As Double, ByRef UoutVec() As Double, ByRef FiltKoeff() As Double, Spalte As Integer)
Dim l As Integer
Dim M As Integer
ReDim YAlt(0 To 4)
ReDim UAlt(0 To 4)
Dim val As Double
Dim Anz As Long
Anz = UBound(UinVec, 1) - LBound(UinVec, 1) + 1
For l = 0 To Anz - 1
UAlt(0) = UinVec(l, Spalte) 'Neuer Wert U(n) am Eingang
val = 0
For M = 0 To 4
val = val + FiltKoeff(M, 1) * UAlt(M) 'summiere alle di*U(n-i)
Next M
For M = 1 To 4
val = val - FiltKoeff(M, 0) * YAlt(M) 'subtrahiere alle ci*Y(n-i)
Next M
YAlt(0) = val
For M = 0 To 3
UAlt(4 - M) = UAlt(4 - M - 1)
YAlt(4 - M) = YAlt(4 - M - 1)
Next M
UoutVec(l, Spalte) = val
Next l
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询