필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Kalasagarreddi Kottakota
Kalasagarreddi Kottakota 2021년 11월 24일
편집: James Tursa 2021년 11월 25일
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
the cyclist
the cyclist 2021년 11월 24일
One row of A is 36 elements. One column of B is 36 elements. It is absolutely unclear how to get a 121x1 matrix from that.
Please explain more clearly what you need. Perhaps use a smaller example (e.g. 4x3) to show exactly what the input and output should be.
Adam Danz
Adam Danz 2021년 11월 24일
Prehaps the goal is the multiply a col of A by row of B.

댓글을 달려면 로그인하십시오.

채택된 답변

James Tursa
James Tursa 2021년 11월 25일
편집: James Tursa 2021년 11월 25일
Maybe this is what you want?
C = sum(A .* B.',2)

추가 답변 (1개)

the cyclist
the cyclist 2021년 11월 24일
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
size(V)
ans = 1×2
121 1

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by