confusing regarding two cases of multiplication in MATLAB?

조회 수: 1 (최근 30일)
ABTJ
ABTJ 2020년 2월 16일
답변: Steven Lord 2020년 2월 16일
I know that in MATLAB,we use ".*" and"*" for multiplication of matrices
But when one should use only "*" and when one should also use dot with asterik ".*" ??
Please kindly explain with examples
Especially if one operand is a scalar or 1X1 matrix and 2nd matrix is a row vector or column vector? In that case ,only asterik"*" will be sufficent?

채택된 답변

Jesus Sanchez
Jesus Sanchez 2020년 2월 16일
".*" -> Element-wise multiplication
Example:
[1 2 3].*[1 2 3] = [1*1 2*2 3*3] = [1 4 9]
"*" -> Matrix multiplication
Example:
[1 2 3]*[1 2 3].' = [1*1 +2*2 +3*3] = [1+4+9] = [14]
  댓글 수: 2
ABTJ
ABTJ 2020년 2월 16일
편집: ABTJ 2020년 2월 16일
what if one operand is a scalar or 1X1 matrix and 2nd matrix is a row vector or column vector? In that case ,only asterik will be sufficent?
Image Analyst
Image Analyst 2020년 2월 16일
In the case where one variable is a scalar, either * or .* would work, though I, and I expect most other people, use only * (without the unneeded dot).

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

추가 답변 (1개)

Steven Lord
Steven Lord 2020년 2월 16일
See this documentation page for a discussion of the difference between array operations and matrix operations, including examples showing what each does.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by