Results 1 to 20 of 27

Thread: VBA Matrix Operations Help Needed.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    VBA Matrix Operations Help Needed.

    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
    Last edited by Paul_Hossler; 02-13-2019 at 02:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •