How to multiply row of matrix A with column of matrix B?

6 Ansichten (letzte 30 Tage)
A is 121 x 36 matrix
B is 36 x 121 matrix
The result C should be 121 x 1 matrix.
May I know how should I multiply a row of A with col of B? so that resulting matrix is 121 X 1.
No loops please.
  2 Kommentare
Adam Danz
Adam Danz am 24 Nov. 2021
Prehaps the goal is the multiply a col of A by row of B.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

James Tursa
James Tursa am 25 Nov. 2021
Bearbeitet: James Tursa am 25 Nov. 2021
Maybe this is what you want?
C = sum(A .* B.',2)

Weitere Antworten (1)

the cyclist
the cyclist am 24 Nov. 2021
If @Adam Danz is correct that you actually want to multiply all the elements of one column of A with one row of B, then
% Define A and B
A = rand(121,36);
B = rand(36,121);
% Which row and column?
colA = 2;
rowB = 3;
% Multiply the selected row and column
V = A(:,colA) .* B(rowB,:).'; % <----- Note that I used the transpose here
% Check the size of V
ans = 1×2
121 1


Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by