Dot product of a column vector by its own elements
5 views (last 30 days)
Show older comments
Hi, I have a matrix containing coordinates(x,y,z) and I am trying to find the dot product of the elements inside the vector. The matrix looks like this:
% a(x) a(y) a(z)
-0.0022 -0.0131 0.9999
% b(x) b(y) b(z)
-0.8062 0.2794 0.5216
% c(x) c(y) c(z)
-0.9325 0.0547 -0.3570
I want to achieve a dot product matrix of something like this:
a.a a.b a.c
b.a b.b b.c
c.a c.b c.c
I tried writing a code
Dot_P(1,1)= dot(matrix(1,:),matrix(1,:));
Dot_P(1,2)= dot(matrix(1,:),matrix(2,:));
Dot_P(1,3)= dot(matrix(1,:),matrix(3,:));
but this is hard coding and is not efficient, any help is appreciated!
2 Comments
Accepted Answer
More Answers (1)
Fangjun Jiang
on 7 Feb 2018
a=[-0.0022 -0.0131 0.9999];
b=[-0.8062 0.2794 0.5216];
c=[-0.9325 0.0547 -0.3570];
M=[a;b;c]
M*M'
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!