This code is originally much longer and intends to use Savitsky-golay fitting to take derivative estimates. In order to take find the derivative matrix needed to fit against original data, I need to follow through a series of excel worksheet functions (namely: Golay_matrix=MMult(MInverse(MMult(Transpose(matrix), matrix)), Transpose(matrix))) I'm relatively new to excel vba and feel like I have exhausted most avaiable resouces trying to solve what appears to be a WorksheetFunction problem. I can code in a transpose function myself, but I would rather not try to code in a MInverse function.. since eventually I will need to use MInverse, MMult, etc., I figured it best if I figured out what was going wrong with the front portion of my code.
I would love any bit of your help!! Thanks!!
Function d_ar(ends As Integer, fit As Integer) As Double()
Dim lngt As Integer 'length of "huge" array
Dim i As Integer
Dim n As Integer
lngt = ends * 2 + 1
Dim huge() As Variant 'array to transpose
For i = 1 To fit + 1
For n = 1 To lngt
ReDim huge(1 To n, 1 To i)
huge(n, i) = (-ends + n - 1) ^ (i - 1)
Next n
Next i
Dim t_hg() As Variant 'transpose of "huge" matrix
ReDim t_hg(1 To i - 1, 1 To n - 1)
t_hg = Application.WorksheetFunction.Transpose(huge)
Cells(1, 15).value = t_hg(1, 2) 'value of zero is returned, but should be -7
End Function