ddanmcgrew
Joined: 14 Nov 2008 Posts: 7 Location: Seattle
|
Posted: Fri Jun 26, 2009 4:56 pm Post subject: MINVERSE FUNCTION, ERROR 13 TYPE MISMATCH |
|
|
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 |
|