Multiplying each row vector with each column vector.
6 次查看(过去 30 天)
显示 更早的评论
I have two matrix X and Y of shape 7800x784 and 784x7800. X !=Y'. I want to multiply each row of X with each column of Y to get a 7800x1 matrix. Basically I want the diagonal elements of X*Y matrix without performing the redundant operations. Is there a vectorised way of performing this operation? Thanks!!
0 个评论
采纳的回答
KSSV
2018-4-12
X = rand(7800,784) ;
Y = rand(784,7800) ;
Z = zeros(1,7800) ;
for i = 1:7800
Z(i) = X(i,:)*Y(:,i) ;
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!