matrices multiplication , the description below

2 次查看(过去 30 天)
% W,H values is for example .. They can be with any dimension but always the number of rows of H is equal to the number of columns of W and the matrices are not squared .
% when i=1 ... Alfa_1 is the multiplication between the first row of H and the first column of W and Alfa _2 is the sum of multiplying the other rows and columns except for the multiplication between the first row of H and the first column of W
% when i=2 ... Alfa_1 is the between the second row of H and the second column of W and Alfa _2 is the sum of multiplying the other rows and columns except for the multiplication between the second row of H and the second column of W.
And goes like this to the end of iterations, also (k) is equal to the number of rows of H and the number of columns of W
H=[1 2 2 1 ; 3 1 1 2;1 3 2 4]
W=[4 1 2 ;1 3 2 ;2 1 3;2 1 4]
for i=1:k
Alfa_1 = H(i,:)*W(:,i);
Alfa_2 = ........
end
  3 个评论
Rik
Rik 2021-12-15
matrices multiplication , the description below
% W,H values is for example .. They can be with any dimension but always the number of rows of H is equal to the number of columns of W and the matrices are not squared .
% when i=1 ... Alfa_1 is the multiplication between the first row of H and the first column of W and Alfa _2 is the sum of multiplying the other rows and columns except for the multiplication between the first row of H and the first column of W
% when i=2 ... Alfa_1 is the between the second row of H and the second column of W and Alfa _2 is the sum of multiplying the other rows and columns except for the multiplication between the second row of H and the second column of W.
And goes like this to the end of iterations, also (k) is equal to the number of rows of H and the number of columns of W
H=[1 2 2 1 ; 3 1 1 2;1 3 2 4]
W=[4 1 2 ;1 3 2 ;2 1 3;2 1 4]
for i=1:k
Alfa_1 = H(i,:)*W(:,i);
Alfa_2 = ........
end

请先登录,再进行评论。

采纳的回答

Soniya Jain
Soniya Jain 2021-6-27
I consider you want to find Alfa_1 and Alfa_2 at each iteration, so you can modify the above code as,
H=[1 2 2 1 ; 3 1 1 2;1 3 2 4];
W=[4 1 2 ;1 3 2 ;2 1 3;2 1 4];
[k,l]=size(H);
for i=1:k
Alfa_1(i) = H(i,:)*W(:,i);
Alfa_2(i) = 0;
for j=1:k
Alfa_2(i) = Alfa_2(i) + H(i,:)*W(:,j);
end
Alfa_2(i) = Alfa_2(i) - Alfa_1(i);
end
Alfa_1 and Alfa_2 are the arrays which contains value of each iteration.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by