vector matrix multiplication single row
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
is there a chance to multiply this way rand(1,10)*rand(10,100) but the way of calculation is each singe element of 1x10 mtx should multiply entire row of 10x100 mtx
0 commentaires
Réponses (2)
Andrei Bobrov
le 23 Oct 2012
a = rand(1,10);
b = rand(10,100);
out = bsxfun(@times,a.',b);
0 commentaires
Jan
le 23 Oct 2012
Modifié(e) : Jan
le 23 Oct 2012
While I'd prefer BSXFUN as Andrei has posted already, there is an alternative:
a = rand(10,1); % Transposed!
b = rand(10,100);
R = a(:, ones(1, 100)) .* b;
Time measurements seems like the ONES is not created explicitely, such that this is more efficient than it looks like.
0 commentaires
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!