Hi … here's a snippet from a macro I'm working on … I can't get the last statement (multiply a matrix by the inverse of another matrix) Everything else works but the last statement:
Option Explicit Option Base 1 Sub Coefficients() Dim C() As Variant Dim D() As Variant Dim F() As Variant ReDim C(1 To 2, 1 To 2) ReDim D(1 To 2, 1 To 1) ReDim F(1 To 2, 1 To 1) ReDim Cinv(1 To 2, 1 To 2) 'Set initial conditions W1 = 0 Del1 = 0.05 ' Swirl Chamber Coefficient Assembly C(1, 1) = Del1 * W1 C(1, 2) = Del1 ^ 2 C(2, 1) = ((A2 - B2) * Del1 * W1 ^ 2) C(2, 2) = ((A2 - 2 * B2 + 1) * Del1 ^ 2 * W1) D(1, 1) = B1 / A1 D(2, 1) = C2 * W1 ActiveSheet.Range("T5") = C(1, 1) ActiveSheet.Range("U5") = C(1, 2) ActiveSheet.Range("T6") = C(2, 1) ActiveSheet.Range("U6") = C(2, 2) ActiveSheet.Range("X5") = D(1, 1) ActiveSheet.Range("X6") = D(2, 1) ' Get F ' Note: we have {C}dx/dt={D} ... need: dx/dt={F}=[C_inverse]{D} F = WorksheetFunction.MMult(WorksheetFunction.MInverse(C), D) --- this is the statement that bombs!!! End Sub




Reply With Quote