Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: element-wise division
Date: Mon, 15 Jun 2009 20:45:18 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 30
Message-ID: <h16bst$sft$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245098718 29181 172.30.248.37 (15 Jun 2009 20:45:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 15 Jun 2009 20:45:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1875128
Xref: news.mathworks.com comp.soft-sys.matlab:547674


Hi, 
Given matrix M1 and vector W, I need to construct a matrix M2.  

v1 = [1 2 3 4]
v2 = [5 6 7 8]
v3 = [1 3 4 5]
v4 = [3 4 5 6]

M1 := 
v1*v3'    v1*v2'
v2*v4'     0
0           v3*v4
0            0

then we are given a vector  W = [w1 w2 w3 w4]' 
w1 = 2
w2 = 3
w3 = 4
w4 = 5

we want to construct a matrix M2 most efficiently from W (without loop, use sparse matrix ) such that

M1 ./ M2 = 
v1*v3'/(w1*w3)   v1*v2'/(w1*w2)
v2*v4'/(w2*w4)     0
0                         v3*v4'/(w3*w4)
0                          0

Thanks
Diego