Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations pierreick on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inverse matrix in VBA, and VBA equiv. for the ":" in Matlab

Status
Not open for further replies.

compositeFEA

Mechanical
Jun 26, 2011
9
Hello everyone,

I am looking for an easy way to calculate the inverse of a matrix in VBA. The matrix is 3-D: 3 x 3 x n (with n variable). What I need is the inverse of each "3x3" plane, therefore I would like to use a For/Next loop from 1 to n to do it. I know I could use the following code in Matlab:

Code:
for i=1:n
   A(:,:,i) = inv(B(:,:,i))
end

Is there a similar way to do this in VBA? What is the VBA equivalent for the ":" in Matlab?

Thanks for your help!

 
Replies continue below

Recommended for you

There is a trick here:
for extracting a row or column array from a 2D array, but it won't work on a 3D array.

I'm pretty sure you will need to use a loop.

As noted in the link provided by Noway2, if you want to use Worksheetfunction.Inverse the array will need to be declared as a variant.

Alternatively you could write your own routine to do the inversion, which could work directly on the 3D array.

Doug Jenkins
Interactive Design Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor