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
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 CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by