confusing regarding two cases of multiplication in MATLAB?

1 次查看(过去 30 天)
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 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by