Dieser Code berechnet Zwischenwerte für ein Array von Werten,
um den entsprechenden Graphen für sie zu zeichnen. Funktioniert
nur bei gleichmäßiger Verteilung der Anfangswerte. Hierbei
wird die Interpolation Sin(X)/X benutzt, welche alle
Anfangswerte in die Berechnung eines einzelnen Zwischenwertes
einfließen lässt.
25.12.2002 Online gestellt
Autor: Dominik Auras <Dominik_auf_vbinside.de>
Code aus Form1.frm
Option ExplicitPrivate Sub Command1_Click()
Dim a() As Double, b As Variant, dx As Double, x As Long
Dim dw As Double, pi As Double, fx As Double, res As Double
Dim nx As Long, k As Long
Dim w As Double, left As Double, right As Double, h As Double
Dim n As Double, i As Double
pi = 4 * Atn(1)
b = Array(9.54415868243651E-04, -2.72719629699598E-06, _
-9.45246299835315E-03, -2.5280372939499E-03, _
3.08337343853428E-02, -1.37651348381862E-02, _
-0.085661188331658, 0.16336854055699, 0.623359641034417, _
0.623359641034416, 0.163368540556989, _
-8.56611883316589E-02, -1.37651348381865E-02, _
3.08337343853427E-02, -2.5280372939499E-03, _
-9.45246299835315E-03, -2.72719629699598E-06, _
9.54415868243651E-04)
k = 200
For x = 0 To UBound(b)
b(x) = b(x) * k
Next x
ReDim a(Picture1.ScaleWidth)
dw = Int(UBound(a) / UBound(b))
For x = LBound(a, 1) To UBound(a, 1)
dx = x / dw
res = 0
For nx = LBound(b, 1) To UBound(b, 1)
If dx = nx Then
fx = 1
Else
fx = ((Sin(pi * (dx - nx))) / (pi * (dx - nx)))
End If
res = res + fx * b(nx)
Next nx
a(x) = res
Next x
w = Picture1.ScaleWidth
h = Picture1.ScaleHeight
left = -w / 2
right = w / 2
For i = left To right
n = Abs(i + right) Mod UBound(a)
If n <> 0 Then
Picture1.Line -(i + w / 2, h / 2 - a(n)), RGB(255, 0, 0)
End If
Next i
Picture1.Line (0, h / 2)-(w, h / 2), RGB(0, 255, 0)
End Sub