Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm trying to subtract all the individual elements of two matrices. One of the matrices is calculated using this function: Function CovarianceMatrix(rng As Range) As Variant Dim i As Integer Dim j As Integer Dim colnum As Integer Dim rownum As Integer Dim auxCovarianceMatrix() As Variant colnum = rng.Columns.Count ' covariance matrix ReDim auxCovarianceMatrix(colnum - 1, colnum - 1) For i = 1 To colnum For j = 1 To colnum auxCovarianceMatrix(i - 1, j - 1) = Application.WorksheetFunction.Covar(rng.Columns(i) , rng.Columns(j)) Next j Next i CovarianceMatrix = auxCovarianceMatrix End Function the other matrix (named avcovariancematrix) is calculated using a very similar formula. I verified that both of these functions work well in the worksheet. Now I need to subtract all the individual elements of both matrices (basic matrix operation), but I'm getting errors and I don't understand why. I created a new function that calls the function I posted above and the other one. This is the function I'm using: Function AddMAtrix(rng as range) as variant Aux1=CovarianceMatrix(rng) Aux2=AverageCovarianceMatrix(rng) AddMatrix=Aux1-Aux2 end function thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Accessing individual elements of an array returned by a function | Excel Programming | |||
Calculate and display individual error bars for individual points | Charts and Charting in Excel | |||
Calculate and display individual error bars for individual points | Charts and Charting in Excel | |||
How to compute the inverse of a matrix with some complex elements | Excel Worksheet Functions | |||
How to do matrix operation with complex number elements in Excel | Excel Worksheet Functions |