필터 지우기
필터 지우기

Dot Multiplication in MATLAB

조회 수: 5 (최근 30일)
Saunok Chakrabarty
Saunok Chakrabarty 2024년 2월 20일
댓글: Saunok Chakrabarty 2024년 2월 22일
I am a bit confused about how dot multiplication (.*) works in MATLAB. For example, [1 2]' .* [1 2; 3 4] = [1 2; 6 8]. So it seems that each row of the first matrix is being multiplied by the corresponding row in the second matrix. However, [1 2] .* [1 2 3 4]' = [1 2; 2 4; 3 6; 4 8] - it seems that each column of the first matrix is being multiplied by the column vector in the second matrix. Further, [1 2] .* [1 2; 3 4; 5 6]' is not possible because of size incompatibility.
How is the multiplication being carried out? I am using MATLAB R2021b.

채택된 답변

Matt J
Matt J 2024년 2월 20일
편집: Matt J 2024년 2월 20일
For matrices A and B, the rule is generally that A.* B is element-by-element multiplication a(i,j).*b(i,j), which means that normally all dimensions of A and B must be equal. However if ever size(A,n)=1 and size(B,n)~=1 (or vice versa), then A will be implicitly copied along dimension n until size(A,n)=size(B,n) and similarly for B.
  댓글 수: 2
Saunok Chakrabarty
Saunok Chakrabarty 2024년 2월 22일
Thanks Matt! This clarifies my doubt. Apologies for the late acceptance.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by