LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Subtract all individual elements of two matrix

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing individual elements of an array returned by a function [email protected] Excel Programming 1 March 19th 08 06:13 AM
Calculate and display individual error bars for individual points del Charts and Charting in Excel 2 March 31st 06 05:11 PM
Calculate and display individual error bars for individual points del Charts and Charting in Excel 1 March 31st 06 04:24 AM
How to compute the inverse of a matrix with some complex elements Annoushka42 Excel Worksheet Functions 0 March 6th 06 12:08 AM
How to do matrix operation with complex number elements in Excel WILSON CHIRAMAL Excel Worksheet Functions 1 August 15th 05 02:26 PM


All times are GMT +1. The time now is 11:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"