Description:
This function returns a Jacbian Matrix of partial derivatives for a function.
eg., usage:
'function for which Jacobian matrix needs to be computed Public Function myfn(x As Variant, p As Variant) Dim outVec As Variant ReDim outVec(1 To UBound(x, 1), 1 To 1) Dim i As Single For i = 1 To UBound(x, 1) outVec(i, 1) = p(1, 1) * x(i, 1) ^ 3 - p(2, 1) * x(i, 1) + 4 Next i myfn = outVec End Function
'example code for getting jacobian matrix Private Sub CommandButton1_Click() ReDim x(1 To 10, 1 To 1) Dim i As Single For i = 1 To 10 x(i, 1) = i Next i ReDim p(1 To 2, 1 To 1) p(1, 1) = 0.5 p(2, 1) = 0.2 ReDim dp(1 To 2, 1 To 1) dp(1, 1) = 0.001 dp(2, 1) = 0.001 Dim myres As Variant myres = GetJacobianMatrix(x, p, "myfn", dp) End Sub
Got a question or problem with this link? Just enter your message and click on submit. No registration is required.
|