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: Hung Lu

Date: 6 Feb, 2013 03:37:08

Message: 1 of 3

Hello,

Does anyone know how I would multiply a matrix A=[5x1x100] by itself to get a new matrix AA=[5x5x100];

I know I can do this using a for loop, but I want to try not to use a for loop unless I have too.

Thank you

HL

Subject: Matrix Multipication

From: James Tursa

Date: 6 Feb, 2013 06:54:08

Message: 2 of 3

"Hung Lu" wrote in message <kesj54$f1b$1@newscl01ah.mathworks.com>...
> Hello,
>
> Does anyone know how I would multiply a matrix A=[5x1x100] by itself to get a new matrix AA=[5x5x100];
>
> I know I can do this using a for loop, but I want to try not to use a for loop unless I have too.

AA = mtimesx(A,A,'t');

You can find MTIMESX here:

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

James Tursa

Subject: Matrix Multipication

From: Bruno Luong

Date: 6 Feb, 2013 07:22:08

Message: 3 of 3

"Hung Lu" wrote in message <kesj54$f1b$1@newscl01ah.mathworks.com>...
> Hello,
>
> Does anyone know how I would multiply a matrix A=[5x1x100] by itself to get a new matrix AA=[5x5x100];
>

AA = bsxfun(@times, A, reshape(A, [1 5 100]))

% Bruno

Tags for this Thread

No tags are associated with 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