help-octave
[Top][All Lists]
Advanced

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

Applying each element of a vector to each row of a matrix


From: Jordi Gutiérrez Hermoso
Subject: Applying each element of a vector to each row of a matrix
Date: Sun, 19 Dec 2010 09:33:20 -0600

I'm often found with a situation in which I have some matrix A and
some vector v and I would like to do something like multiply each
column or row in A by each element of v. I've wished that something
like A.*v or v.*A would do this if the row or column dimensions of A
matched those of v, but of course this doesn't work. I end up
resorting to repmat instead to turn v into a matrix whose dimensions
match those of A.

My questions are, is there another way to do this more cleanly without
first calling repmat? If there isn't, would this be a reasonable
extension of the elementwise operators?

Thanks in advance,
- Jordi G. H.


reply via email to

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