Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Multiplying row of matrix by vector many times
Date: Mon, 15 Mar 2010 07:29:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <hnknk1\$l33\$1@fred.mathworks.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1268638145 21603 172.30.248.37 (15 Mar 2010 07:29:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 15 Mar 2010 07:29:05 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:616784

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