help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A vectorization question


From: marco atzeri
Subject: Re: A vectorization question
Date: Tue, 20 Dec 2011 11:22:59 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 12/20/2011 11:07 AM, marco atzeri wrote:
On 12/20/2011 10:53 AM, wrote:
Hi,

Is there a way of getting rid of this loop in

for j=1:n
B(:,j)=c(j) * A(:,j);
endfor

where c is a n-vector and A is a m by n matrix?

Regards,
ST

Am I missing something or it is just a standard matrix multiplication ?

B=A*c

or use c' depending if its size is nx1 or 1xn

Marco

No, you are asking for a brodcasting as B is same size of A

B=A.*c
on the latest development,

otherwise on 3.4.x
B=A.*repmat(c,m,1)

Regards
Marco



reply via email to

[Prev in Thread] Current Thread [Next in Thread]