MATLAB: Dot product of a column vector by its own elements

dot productfor loopmatrix manipulation

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!

Best Answer

With some guessing:
X = [-0.0022, -0.0131, 0.9999; ...
-0.8062, 0.2794, 0.5216; ...
-0.9325, 0.0547, -0.3570];
P = X * X.'
Now your "c" is X(1, :). Then e.g. P(3,3) equals c * c'.