Hi guys,
I'm a total newbie and am trying to use mmult in VBA..
All i want to do is multiply 2 matrices (3x3 and 3x1), so that I can use that matrix for more complicated calculations.
Need help on a UDF that returns the final result as a matrix (i.e. 3x1 matrix)
Function matt()
Dim P(1 To 3, 3)
P(1, 1) = 1
P(1, 2) = 2
P(1, 3) = 3
P(2, 1) = 4
P(2, 2) = 5
P(2, 3) = 6
P(3, 1) = 7
P(3, 2) = 8
P(3, 3) = 9
Dim Q(1 To 3, 1)
Q(1, 1) = -1
Q(2, 1) = -2
Q(3, 1) = -3
Dim result(1 To 3, 1)
result = Application.WorksheetFunction.MMult(P, Q)
matt = result
End Function
Thanks in advance!!!
Matt
I'm a total newbie and am trying to use mmult in VBA..
All i want to do is multiply 2 matrices (3x3 and 3x1), so that I can use that matrix for more complicated calculations.
Need help on a UDF that returns the final result as a matrix (i.e. 3x1 matrix)
Function matt()
Dim P(1 To 3, 3)
P(1, 1) = 1
P(1, 2) = 2
P(1, 3) = 3
P(2, 1) = 4
P(2, 2) = 5
P(2, 3) = 6
P(3, 1) = 7
P(3, 2) = 8
P(3, 3) = 9
Dim Q(1 To 3, 1)
Q(1, 1) = -1
Q(2, 1) = -2
Q(3, 1) = -3
Dim result(1 To 3, 1)
result = Application.WorksheetFunction.MMult(P, Q)
matt = result
End Function
Thanks in advance!!!
Matt