Thanks for the help.
Matrix Operations from within VBA
The following subroutine is called from another subroutine. Arrays p, vr,
vi, Qr, Qi and Pinv were dimensioned Dim p(), etc prior to the subroutines.
All arrays are Real. The matrix operation for Pinv() worked fine. The
operations for vr and vi arrays also worked fine. However, when calculations
got to Qr, I received an error message “Run Time Error ‘1001†unable to get
MMult property of the worksheetFunction.class. “nc†is 8 in the following.
Can anyone help?
Note, I wrote a very simple VBA routine to multiply a 3X3 times a 3X1 matrix
and called the resultant matrix “Câ€. C should be of dimensions 3X1. I
included a MsgBox(C(1)) and the program hung up. When I changed it to
MsgBox(C(1,1)), the program ran. Note, C was dimensioned (as a 1X3) … Dim
C(1 To 3) array.
Sub Qmatrix()
ReDim vr(1 To nc), vi(1 To nc), Qr(1 To nc), Qi(1 To nc), Pinv(1 To nc, 1 To
nc)
Pinv() = Application.WorksheetFunction.MInverse(p())
For j = 1 To nc
vr(j) = v(j) * Cos(va(j) * pi / 180)
vi(j) = v(j) * Sin(va(j) * pi / 180)
Next j
Qr = Application.WorksheetFunction.MMult(Pinv, vr)
Qi = Application.WorksheetFunction.MMult(Pinv, vi)
End Sub
Dana DeLouis said:
How do I do matrix operations from within an Excel VBA macro?
Hi. One way...
Sub Demo()
Dim a, m
a = [{3,4; 5,6}]
With WorksheetFunction
m = .MMult(a, a)
m = .MInverse(a)
End With
End Sub
= = = = = = =
HTH :>)
Dana DeLouis
Kirby Holte wrote:
How do I do matrix operations from within an Excel VBA macro?
Specifically matrix multiplication (MULT) and matrix inversion
(MINVERT).
*** Sent via Developersdex
http://www.developersdex.com ***