Advertisement
Guest User

Untitled

a guest
May 30th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. Function int_kw_popr(zakres_X As Range, zakres_Y As Range, x0) As Single
  2. Dim x2w(1 To 3, 1 To 3) As Single
  3. Dim x(1 To 3) As Single
  4. Dim y(1 To 3) As Single
  5. Dim i As Integer, n As Integer, j As Integer
  6. Dim bmin As Single
  7. n = zakres_X.Cells.Count
  8. bmin = WorksheetFunction.Large(zakres_X, 1) + WorksheetFunction.Large(zakres_X, 2) + WorksheetFunction.Large(zakres_X, 3)
  9. For i = 1 To n - 2
  10. If Abs(zakres_X.Cells(i) + zakres_X.Cells(i + 1) + zakres_X.Cells(i + 2) - 3 * x0) < bmin Then
  11. bmin = Abs(zakres_X.Cells(i) + zakres_X.Cells(i + 1) + zakres_X.Cells(i + 2) - 3 * x0)
  12. j = i
  13. End If
  14. Next i
  15. For i = 1 To 3
  16. x(i) = zakres_X.Cells(j + i - 1): y(i) = zakres_Y.Cells(j + i - 1)
  17. Next i
  18. x2w(1, 1) = 1: x2w(2, 1) = 1: x2w(3, 1) = 1 'tworzenie macierzy 3x3
  19. x2w(1, 2) = x(1): x2w(2, 2) = x(2): x2w(3, 2) = x(3)
  20. x2w(1, 3) = x(1) ^ 2: x2w(2, 3) = x(2) ^ 2: x2w(3, 3) = x(3) ^ 2
  21. A = WorksheetFunction.MMult(WorksheetFunction.MInverse(x2w), WorksheetFunction.Transpose(y))
  22. int_kw_popr = A(1, 1) + A(2, 1) * x0 + A(3, 1) * x0 * x0
  23. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement