confusing regarding two cases of multiplication in MATLAB?

2 Ansichten (letzte 30 Tage)
ABTJ
ABTJ am 16 Feb. 2020
Beantwortet: Steven Lord am 16 Feb. 2020
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?

Akzeptierte Antwort

Jesus Sanchez
Jesus Sanchez am 16 Feb. 2020
".*" -> 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 Kommentare
ABTJ
ABTJ am 16 Feb. 2020
Bearbeitet: ABTJ am 16 Feb. 2020
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 am 16 Feb. 2020
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).

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

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

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by