Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matrix multipication

Subject: matrix multipication

From: doron bartov

Date: 18 Apr, 2012 15:07:07

Message: 1 of 3

hi,

i need to multiply a 4-d matrix with a vector in the following way:

the 4d array is an (n,n,3,3) 4d matrix which represents a matrix of 3x3 matrices

the lenght of the vector in nxn, i could use a for loop to multiply each block matrix with the according scalar elemnt in the scalar but this will significantly hurt my efficiency

any help?

Subject: matrix multipication

From: Matt J

Date: 18 Apr, 2012 15:27:07

Message: 2 of 3

"doron bartov" <doronbartov@gmail.com> wrote in message <jmmlaq$pcb$1@newscl01ah.mathworks.com>...
> hi,
>
> i need to multiply a 4-d matrix with a vector in the following way:
>
> the 4d array is an (n,n,3,3) 4d matrix which represents a matrix of 3x3 matrices
>
> the lenght of the vector in nxn, i could use a for loop to multiply each block matrix with the according scalar elemnt in the scalar but this will significantly hurt my efficiency
>
> any help?


Use the BSXFUN command

Subject: matrix multipication

From: Matt J

Date: 18 Apr, 2012 15:30:08

Message: 3 of 3

"doron bartov" <doronbartov@gmail.com> wrote in message <jmmlaq$pcb$1@newscl01ah.mathworks.com>...
>
> the 4d array is an (n,n,3,3) 4d matrix which represents a matrix of 3x3 matrices

Incidentally, it is better to have this as a 3x3xnxn matrix. It is more efficient to extract a 3x3 matrix from a 4D array as

A(1:3,1:3,i,j)
 
than as

A(i,j, 1:3, 1:3)

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us