1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| Function IntegrDataC(xi, yi, Optional degree)
Dim vy, vx, Nodes, si, nx&, ny&, i&, r, n&
Dim BX, By, h, s, j&
Dim Coeff_NC(), kd 'Newton-Cotes Coefficient,
LoadVector vy, yi, nx
LoadVector vx, xi, ny
If IsMissing(degree) Then degree = 1
Nodes = ny
'check nodes and integration degree
If degree + 1 > Nodes Then IntegrDataC = "?": Exit Function
'algorithm begins---------------------------------------------
si = 0
If degree = 1 Then
For i = 2 To Nodes
si = si + (vy(i) + vy(i - 1)) * (vx(i) - vx(i - 1))
Next i
si = si / 2
ElseIf degree > 1 Then
r = (Nodes - 1) Mod degree
n = Nodes
If r > 0 Then n = Nodes + degree - r
DataEquiSpace vx, vy, BX, By, n, h, degree
Formula_Newon_Cotes_get kd, Coeff_NC, degree + 1
For i = degree + 1 To n Step degree
s = 0
For j = 1 To degree + 1
s = s + By(i - j + 1) * Coeff_NC(j)
Next j
si = si + h * s / kd
Next i
End If
IntegrDataC = si
End Function |
Partager