Anthony's VBA ForumWhere the knowledge is shared

 Who's Online [ Administrator ][ Moderator ]

Author Message
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
ddanmcgrew

Joined: 14 Nov 2008
Posts: 7
Location: Seattle

 Posted: Mon Jun 29, 2009 1:54 pm    Post subject: The problem was not with the code. The Matrix is singular which means the determanent = 0 and is not invertable Dangerous Dan Mcgrew
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 4 Hours Page 1 of 1

 Jump to: Select a forum Excel VBA----------------General Excel VBA VBA on Finance and Investment----------------Option Pricing ModelsPortfoilio OptimizationOther Finance Topics VBA on Statistics----------------Probability DistributionsMonte Carlo SimulationRegression Analysis Announcement----------------Updated News
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