Matrix Functions not Running

trough

Board Regular
Joined
Oct 26, 2010
Messages
55
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
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I think your problem might be the scope of your variables you define Q in the function CalcQbar and you also define Q in the function CalcQ these two variables are completley different entities so what ever you put into Q in calcQ DOES NOT appear in Q in CalcQbar. If you wnt to transfer variable from one function to another you need to define them at the top of the module.
The other think I have just spotted is that you are assigning Q in CalcQbar to the function Calcq() this function is not type defined so it defaults to a single variant so the won't work with mmult
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,431
Messages
6,124,855
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top