[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Applying each element of a vector to each row of a matrix
From: |
Judd Storrs |
Subject: |
Re: Applying each element of a vector to each row of a matrix |
Date: |
Sun, 19 Dec 2010 20:06:36 -0500 |
The bsxfun function does a lot of this. Assume
a = ones(10) ;
v = 1:10 ;
Multiply each column of a by the corresponding element of v:
bsxfun(@times, a, v)
Multiply each row of a by the corresponding element of v:
bsxfun(@times, a, v')
Raise each column of a to the corresponding power of v:
bsxfun(@power, a, v)
Raise each row of a to the corresponding power of v:
bsxfun(@power, a, v')
--judd
- Re: Applying each element of a vector to each row of a matrix, (continued)
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Martin Helm, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Martin Helm, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Olaf Till, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jonathan Webster, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix, Jonathan Webster, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix,
Judd Storrs <=
- Re: Applying each element of a vector to each row of a matrix, Martin Helm, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Francesco Potortì, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix, Judd Storrs, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix, Judd Storrs, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/20
Re: Applying each element of a vector to each row of a matrix, Jaroslav Hajek, 2010/12/20