![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 76
|
I am trying to convert a lower diagonal matrix to a symmetric matrix using the following simple function. It works great for matrix of size 60X60 for sure, I tried using it for 120X120 matrix and it failed.
Is there something I am doing wrong! Here is the function code! Function fullmatrix(matrix) As Variant Set therange = matrix nrows = matrix.Rows.Count ReDim matrix(1 To nrows, 1 To nrows) As Double Dim outp1() As Double ReDim outp1(1 To nrows, 1 To nrows) For i = 1 To nrows For j = 1 To i outp1(i, j) = therange.Cells(i, j) Next Next For j = 1 To nrows For i = j + 1 To nrows outp1(j, i) = outp1(i, j) Next Next End If fullmatrix = outp1() End Function |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Posts: 76
|
Sorry, there is no end if!
Corrected code here... I am trying to convert a lower diagonal matrix to a symmetric matrix using the following simple function. It works great for matrix of size 60X60 for sure, I tried using it for 120X120 matrix and it failed. Is there something I am doing wrong! Here is the function code! Function fullmatrix(matrix) As Variant Set therange = matrix nrows = matrix.Rows.Count ReDim matrix(1 To nrows, 1 To nrows) As Double Dim outp1() As Double ReDim outp1(1 To nrows, 1 To nrows) For i = 1 To nrows For j = 1 To i outp1(i, j) = therange.Cells(i, j) Next Next For j = 1 To nrows For i = j + 1 To nrows outp1(j, i) = outp1(i, j) Next Next fullmatrix = outp1() End Function |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|