Multiplying each row vector with each column vector.

조회 수: 5 (최근 30일)
Sameer Karim
Sameer Karim 2018년 4월 12일
답변: KSSV 2018년 4월 12일
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일
X = rand(7800,784) ;
Y = rand(784,7800) ;
Z = zeros(1,7800) ;
for i = 1:7800
Z(i) = X(i,:)*Y(:,i) ;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by