A way to compute dot product of an array and a vector

17 ビュー (過去 30 日間)
Elina Park
Elina Park 2018 年 9 月 26 日
編集済み: Torsten 2023 年 7 月 8 日
Hi, So if I have a 2-D array such as
[1 2
3 4
5 6]
and a vector such as
[7 8]
I want to have matlab calculate the dot product of the rows of the array and the vector, and save the results as a column vector. How can I do this?

採用された回答

Walter Roberson
Walter Roberson 2018 年 9 月 26 日
[1 2
3 4
5 6] * [7 8].'
  2 件のコメント
Francesco Bernardini
Francesco Bernardini 2023 年 7 月 8 日
Hi, thank you for the answer, it solved my problem;
however, is the dot before the ' needed?
Usually it means elementwise-operation but here I don't see the connection with the transposition;
Torsten
Torsten 2023 年 7 月 8 日
編集済み: Torsten 2023 年 7 月 8 日
.' means: usual transpose
' means: conjugate transpose
If the arrays are all real-valued, both operations give the same result. If they are complex-valued - not.
a = [1 2];
a'
ans = 2×1
1 2
a.'
ans = 2×1
1 2
a = [1 + 1i , 2-3*1i];
a'
ans =
1.0000 - 1.0000i 2.0000 + 3.0000i
a.'
ans =
1.0000 + 1.0000i 2.0000 - 3.0000i

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by