Jump to content

Recommended Posts

Posted

Hi all,

 

I am trying to understand matrix multiplication in MATLAB.

 

If we have the following two matrices:

 

a b w x

 

c d y z

 

Then, in what order should the elements by multiplied?

 

Any help is greatly appreciated.

 

Tridimity

 

 

Posted (edited)

I have no idea what AAA is talking about...

 

if you have matrix A with elements [math]A_{ij}[/math] and matrix B with elements [math]B_{jk}[/math] (and I picked the dimensions on purpose there.... the second dimension of A has to equal the first dimension of B, hence they both used j)

 

The matrix C = A * B will be defined by

 

[math]C_{ik} = \sum^m_{j=1}A_{ij}B_{jk}[/math]

 

where m represents the number of columns in A and rows in B.

 

For your 2x2 example:

 

[math]C_{1,2} = \sum^2_{j=1}A_{1,j}B_{j,2} = A_{1,1}B_{1,2} + A_{1,2}B_{2,2}[/math]

 

In terms of what order you do these operations in, there are incredibly fast optimized routines out there. You might want to look at the source of something like BLAS (http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) to see how they code it efficiently. But in terms of getting the right answer, order is unimportant so long as you multiply and add the right things together.

Edited by Bignose

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.