I am performing matrix multiplication of an inverted 2X2 matrix with a 2X1 matrix. I kept getting errors and did some searching and stumbled upon this Question and Answer. The answer is the bit of code below.
Why does y need to be defined as (1 to 2, 1 to 1) instead of just (1 to 2)?
Dim A As Variant Dim y As Variant Dim x As Variant ReDim y(1 To 2, 1 To 1) y(1, 1) = 2 y(2, 1) = 3 ReDim A(1 To 2, 1 To 2) A(1, 1) = 3 A(2, 1) = 1 A(1, 2) = 4 A(2, 2) = 2 x = WorksheetFunction.MMult(WorksheetFunction.MInverse(A), y)
MMULT should have 2D arrays as parameters, since it is used for multiplying 2D matrices. A 1D array cannot be considered as a matrix.
1.4m articles
1.4m replys
5 comments
57.0k users