Multiplication between two matrices with different number of rows

조회 수: 1 (최근 30일)
DV
DV 2022년 7월 11일
댓글: DV 2022년 7월 11일
Dear all,
I have two matrices:
A=[42x5];
B=[32x1];
I want to multiply each row of B to each of A.
Kind help needed. Thank you.
  댓글 수: 2
Stephen23
Stephen23 2022년 7월 11일
@DV: please show us the size of the expected output array.
DV
DV 2022년 7월 11일
Expected to be: C=[42x32x5];
Thanks!

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

채택된 답변

Stephen23
Stephen23 2022년 7월 11일
편집: Stephen23 2022년 7월 11일
C = permute(A,[1,3,2]) .* reshape(B,1,[])
  댓글 수: 2
Stephen23
Stephen23 2022년 7월 11일
Testing:
A = rand(42,5);
B = rand(32,1);
C = permute(A,[1,3,2]) .* reshape(B,1,[]);
size(C)
ans = 1×3
42 32 5
DV
DV 2022년 7월 11일
Thank you sooooo much!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by