I can't figure out why the matrix functions inside the With statement are not executing. Could anyone please advise? Basic pseudo code is below with formula for Qbar shown which is where it stops.
Option Explicit
Option Base 1
Public Pi As Double
Private Function CalcQbar()
Dim Qbar() As Double
Dim Q() As Double
Dim T() As Double
ReDim Qbar(1 To 3, 1 To 3)
ReDim Q(1 To 3, 1 To 3)
ReDim T(1 To 3, 1 To 3)
Pi = Application.WorksheetFunction.Pi()
Q = CalcQ()
T = CalcT()
With Application.WorksheetFunction
Qbar = .MMult(.Transpose(T), .MMult(Q, T))
End With
CalcQbar = Qbar
End Function
Private Function CalcQ()
Dim Q() As Double
ReDim Q(1 To 3, 1 To 3)
' Do some stuff to calculate the 9 cells of Q
'for i = 1 to 3
'for j = 1 to 3
'Q(i,j) = some real number
'next j
'next i
CalcQ = Q
End Function
Private Function CalcT()
Dim T() As Double
ReDim T(1 To 3, 1 To 3)
' Do some stuff to calculate the 9 cells of T
'for i = 1 to 3
'for j = 1 to 3
'T(i,j) = some real number
'next j
'next i
CalcT = T
End Function
Option Explicit
Option Base 1
Public Pi As Double
Private Function CalcQbar()
Dim Qbar() As Double
Dim Q() As Double
Dim T() As Double
ReDim Qbar(1 To 3, 1 To 3)
ReDim Q(1 To 3, 1 To 3)
ReDim T(1 To 3, 1 To 3)
Pi = Application.WorksheetFunction.Pi()
Q = CalcQ()
T = CalcT()
With Application.WorksheetFunction
Qbar = .MMult(.Transpose(T), .MMult(Q, T))
End With
CalcQbar = Qbar
End Function
Private Function CalcQ()
Dim Q() As Double
ReDim Q(1 To 3, 1 To 3)
' Do some stuff to calculate the 9 cells of Q
'for i = 1 to 3
'for j = 1 to 3
'Q(i,j) = some real number
'next j
'next i
CalcQ = Q
End Function
Private Function CalcT()
Dim T() As Double
ReDim T(1 To 3, 1 To 3)
' Do some stuff to calculate the 9 cells of T
'for i = 1 to 3
'for j = 1 to 3
'T(i,j) = some real number
'next j
'next i
CalcT = T
End Function