Info

この質問は閉じられています。 編集または回答するには再度開いてください。

matrix operaions sums multiplications

1 回表示 (過去 30 日間)
Tiina
Tiina 2014 年 12 月 27 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
If I have 2 matrices say
B size (100, 2)
A size (100, n)
How to conduct the following operation?
B(1,1) * A(:,1) + B(1,2) * A(:,2)
Then in another column
B(2,1) * A(:,1) + B(2,2) * A(:,2)
And so on , that is each row of B multiplied by A. with loops or without. Thanks
  1 件のコメント
Image Analyst
Image Analyst 2014 年 12 月 27 日
When do columns 3 to n of A ever get involved in this calculation???

回答 (2 件)

Roger Stafford
Roger Stafford 2014 年 12 月 27 日
C = A(:,1:2)*B.';

Shoaibur Rahman
Shoaibur Rahman 2014 年 12 月 27 日
It seems that A(:,3:end) are never used. If that is the case, then you can simply use a for loop:
for k = 1:size(B,1)
out(:,k) = B(k,1)*A(:,1)+B(k,2)*A(:,2);
end

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by