# confusing regarding two cases of multiplication in MATLAB?

2 ビュー (過去 30 日間)
ABTJ 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 ".*" ??
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 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 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 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 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 Center および File ExchangeMatrix Indexing についてさらに検索

R2015a

### Community Treasure Hunt

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

Start Hunting!

Translated by