×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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!

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

There is a trick here:
http://usefulgyaan.wordpress.com/2013/06/12/vba-tr...
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
http://newtonexcelbach.wordpress.com/

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources