MATLAB: Substracting every row from each other

loopmatrixsubtraction

I am trying to substract every other row using 2 loops, what is wrong with this code?
Here is the code,
% these are the coordinates I am using
coor=[x' y' z'];
%number of the rows is my atomnumber
atomnum=size(x,2);
contactmapdistance=zeros;
for i=atomnum : 1
for j= 1:atomnum
contactmapdistance(i,3)=coor(i,:) - coor(j,:);
i=i-1;
end
j=j+1;
end

Best Answer

coor - reshape(coor.',1,size(coor,2),[])