Thread Subject: matrix multiplication in bsxfun way

Subject: matrix multiplication in bsxfun way

From: Juliette Salexa

Date: 25 Aug, 2011 16:44:10

Message: 1 of 4

I would like to do something like:

a=rand(2,2);
b=rand(2,2,3);
c=bsxfun(@times,a,b)

except I want to do MATRIX MULTIPLICATION instead of @times (which does POINT-WISE MULTIPLICATION).

the result I want should be a 2 x 2 x 3 array where
c(:,:,1) = a*b(:,:,1)
c(:,:,2) = a*b(:,:,2)
c(:,:,3) = a*b(:,:,3)

I vaguely recall ARRAYFUN being able to do something similar, but upon looking at the documentation for ARRAYFUN i couldn't come up with anything.

Thank you,
Juliette

Subject: matrix multiplication in bsxfun way

From: Bruno Luong

Date: 25 Aug, 2011 16:55:30

Message: 2 of 4

Pure Matlab solution:
http://www.mathworks.com/matlabcentral/fileexchange/24260-multiple-same-size-linear-solver

MEX solution (highly recommended):
http://www.mathworks.com/matlabcentral/fileexchange/25977-mtimesx-fast-matrix-multiply-with-multi-dimensional-support

Bruno

Subject: matrix multiplication in bsxfun way

From: Matt J

Date: 25 Aug, 2011 16:58:10

Message: 3 of 4

http://www.mathworks.com/matlabcentral/fileexchange/25977-mtimesx-fast-matrix-multiply-with-multi-dimensional-support

Subject: matrix multiplication in bsxfun way

From: Juliette Salexa

Date: 25 Aug, 2011 18:54:28

Message: 4 of 4

ABSOLUTELY BRILLIANT!

THANK YOU BRUNO AND MATT , AND MOST OF ALL JAMES TURSA.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com