How do I find the dot product of 2 matrices without the same number of elements?

1 回表示 (過去 30 日間)
Christian Jaramillo
Christian Jaramillo 2018 年 10 月 24 日
編集済み: Matt J 2018 年 10 月 25 日
I have the following vectors that I need to find the dot product for using the dot function. here is what I have so far;
A = [1 2 3]
B = [12 20 15 7]
dot(A, B)
  10 件のコメント
Bruno Luong
Bruno Luong 2018 年 10 月 24 日
I guess the book has a typo error.
Image Analyst
Image Analyst 2018 年 10 月 24 日
I don't think 1 and 2 can be done. 3 can be done because for each food item there is a count and a price so you just do sum(count.*price).

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

回答 (1 件)

Haritha
Haritha 2018 年 10 月 25 日
編集済み: Matt J 2018 年 10 月 25 日
Hi,
To create the equal size of a vector you have to do padding.
Example:
A = [1 2 3 0];
B = [12 20 15 7];
dot(A, B)
ans =
97

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by