Anthony's VBA Forum Index Anthony's VBA Forum
Where the knowledge is shared
Menu
 Anthony's VBA Forum IndexHome Page
 Anthony's VBA Forum IndexForum Index
FAQFAQ
MemberlistMemberlist
UsergroupsUsergroups
RegisterRegister
ProfileProfile
Log in to check your private messagesMessages
Log inLogin/Out

Quick Search

Advanced Search

Links
Consulting
Products

Who's Online
[ Administrator ]
[ Moderator ]


MINVERSE FUNCTION, ERROR 13 TYPE MISMATCH

 
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA
View previous topic :: View next topic  
Author Message
ddanmcgrew



Joined: 14 Nov 2008
Posts: 7
Location: Seattle

PostPosted: Fri Jun 26, 2009 4:56 pm    Post subject: MINVERSE FUNCTION, ERROR 13 TYPE MISMATCH Reply with quote

I am writing a large program that uses matrices to calculate stresses in beams. I need to invert large (nxn) matrices. The matrix will vary from 60 to 200 rows and columns. I get a runtime ERROR 13, TYPE MISMATCH. When I use the MINVERSE function.
The matrices are global variables, Dim statement as follows:
Dim GlobalK(), GlobalKInv() as Double then redimmed in the subroutine once the dimensions are known. I have tried lots of variations to get MINVERSE to work. I have printed the matrix GlobalK to make sure it contains no text and that no row or column is all zeros. I have spent about 8 hours trying to work past this one hurdle. Any Ideas?
Included is the code of the entire sub routine. My print matrix routine is a seperate routine

Dangerous Dan McGrew


Private Function LoadGlobalK()

'This function loads the stiffness matrix "K" with data from
'ElemLenArray also Dimensions GlobalF and Globald matricies

Dim N, i, j, k As Integer
Dim Constant, Emod As Double

N = UBound(ElemLenArray, 1)
i = (N + 1) * 2 + 1

ReDim GlobalK(i, i)
ReDim GlobalKInv(i, i)
ReDim GlobalF(i)
ReDim GlobalFo(i)
ReDim Globald(i)

Emod = Worksheets("Input").Cells(14, 3)

'Load GlobalK with zeros to avoid error in matrix multiplication
j = 0
k = 0

Do Until j > i
k = 0
Do Until k > i
GlobalK(j, k) = 0
GlobalKInv(j, k) = 0
k = k + 1
Loop
j = j + 1
Loop

'Load GlobalK with Values

i = 0
j = 0
k = 0

Do Until i > N
Constant = (Emod * ElemLenArray(i, 5)) / ((ElemLenArray(i, 0) * 12) ^ 3)
GlobalK(j, k) = GlobalK(j, k) + 12 * Constant
GlobalK(j, k + 1) = GlobalK(j, k + 1) + 6 * Constant * ElemLenArray(i, 0) * 12
GlobalK(j, k + 2) = GlobalK(j, k + 2) + (-12 * Constant)
GlobalK(j, k + 3) = GlobalK(j, k + 3) + 6 * Constant * ElemLenArray(i, 0) * 12
GlobalK(j + 1, k) = GlobalK(j + 1, k) + 6 * Constant * ElemLenArray(i, 0) * 12
GlobalK(j + 1, k + 1) = GlobalK(j + 1, k + 1) + 4 * Constant * (ElemLenArray(i, 0) * 12) ^ 2
GlobalK(j + 1, k + 2) = GlobalK(j + 1, k + 2) + (-6 * Constant * ElemLenArray(i, 0) * 12)
GlobalK(j + 1, k + 3) = GlobalK(j + 1, k + 3) + 2 * Constant * (ElemLenArray(i, 0) * 12) ^ 2
GlobalK(j + 2, k) = GlobalK(j + 2, k) + (-12 * Constant)
GlobalK(j + 2, k + 1) = GlobalK(j + 2, k + 1) + (-6 * Constant * ElemLenArray(i, 0) * 12)
GlobalK(j + 2, k + 2) = GlobalK(j + 2, k + 2) + 12 * Constant
GlobalK(j + 2, k + 3) = GlobalK(j + 2, k + 3) + (-6 * Constant * ElemLenArray(i, 0) * 12)
GlobalK(j + 3, k) = GlobalK(j + 3, k) + 6 * Constant * ElemLenArray(i, 0) * 12
GlobalK(j + 3, k + 1) = GlobalK(j + 3, k + 1) + 2 * Constant * (ElemLenArray(i, 0) * 12) ^ 2
GlobalK(j + 3, k + 2) = GlobalK(j + 3, k + 2) + (-6 * Constant * ElemLenArray(i, 0) * 12)
GlobalK(j + 3, k + 3) = GlobalK(j + 3, k + 3) + 4 * Constant * (ElemLenArray(i, 0) * 12) ^ 2

i = i + 1
k = k + 2
j = j + 2
Loop

GlobalKInv() = Application.WorksheetFunction.MInverse(GlobalK())

End Function
Back to top
View user's profile Send private message
ddanmcgrew



Joined: 14 Nov 2008
Posts: 7
Location: Seattle

PostPosted: Mon Jun 29, 2009 1:54 pm    Post subject: Reply with quote

The problem was not with the code. The Matrix is singular which means the determanent = 0 and is not invertable

Dangerous Dan Mcgrew
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group