Multiplying each row vector with each column vector.

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!!

 採用された回答

KSSV
KSSV 2018 年 4 月 12 日

0 投票

X = rand(7800,784) ;
Y = rand(784,7800) ;
Z = zeros(1,7800) ;
for i = 1:7800
Z(i) = X(i,:)*Y(:,i) ;
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperating on Diagonal Matrices についてさらに検索

質問済み:

2018 年 4 月 12 日

回答済み:

2018 年 4 月 12 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by