vector matrix multiplication single row
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Jan
2012-10-23
编辑:Jan
2012-10-23
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!