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:
Multiplying row of matrix by vector many times

Subject: Multiplying row of matrix by vector many times

From: Louis

Date: 15 Mar, 2010 07:29:05

Message: 1 of 2

Hi,

I have an m x n matrix A, and a set of p vectors of length n (a p x n matrix B)

If v is a vector in B I would like to compute A.*repmat(v, [m 1]) and I would like to do this for all p vectors.

For example if
A = [1 2 3; 4 5 6]
v = [0 0 1]

I want
[0 0 3; 0 0 6]

and I need to do this for all p vectors.

Is there any way for me to do this without resorting to loops? I was thinking of using 3D matrices and first converting A to repmat(A, [1 1 p]) but then converting B to the desired 3D matrix is tricky without a loop.

Any suggestions?

Thanks

p.s. If it matters, after finding C = A.*repmat(v, [m 1]) I would like to take the horizontal sum and store this vector somewhere and do this p times

Subject: Multiplying row of matrix by vector many times

From: Sadik

Date: 15 Mar, 2010 10:57:05

Message: 2 of 2

Hi Louis,

A reshape after a repmat should help you get B in a suitable 3D matrix.

Best.

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