MATLAB Answers

Vector Dot Product using Matrix

8 views (last 30 days)
Mohammad Fatin Ishtiyaq
Mohammad Fatin Ishtiyaq on 9 Mar 2021
Answered: Sai Veeramachaneni on 12 Mar 2021
As we all know, the dot product of 2 vectors must be a scalar quantity. I have two vectors P and Z and they both have 6138 data points. So i converted them to Matrix of dimension 6138x3. Now when I used dot(P,Z) I am getting a 1x3 matrix. My question is how can I get the scalar quantity from this? Or Is there other way to the dot product of these two vectors using MATLAB.
Jan on 10 Mar 2021
Or simply: A * B.'

Sign in to comment.

Answers (1)

Sai Veeramachaneni
Sai Veeramachaneni on 12 Mar 2021
Refer to this example.
For multidimensional arrays, dot function calculates the dot product of corresponding vectors along the first array dimension whose size does not equal 1.
In your case I think sum(dot(A,B)) works for you.
Hope it helps.

Community Treasure Hunt

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

Start Hunting!