|
"Louis" <tanlouiss+matlab@gmail.com> wrote in message <hnknnm$mlh$1@fred.mathworks.com>...
> 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
sum( repmat(A,p,1) .* ( reshape( repmat( reshape(B,1,p*n), m,1), m*p,n) ), 2)
that must work
|