Thanks:  0
Likes:  0

# Thread: problem with array function

1. 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. 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

## User Tag List

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•