Vector Matrix multiplication (Row wise)
Mostrar comentarios más antiguos
Hi, I need to multiply each row of very large matrix with a row of corresponding vector. I don't really want to use for loop for that, i.e.,
N=15000;
L=rand(N,N); V=rand(N,1);
for i=1:1:N
L(i,:)=V(i)*L(i,:);
end
is it possible to do this in vectorized way?
Thank you
Erdem
Respuesta aceptada
Más respuestas (3)
Vladimir Kazei
el 9 de Oct. de 2017
Editada: Vladimir Kazei
el 9 de Oct. de 2017
2 votos
L = L .* V;
James Tursa
el 16 de Sept. de 2015
L = bsxfun(@times,L,V);
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!