coord(1,1)=-0.6;
coord(1,2)=0;
coord(2,1)=-0.9;
coord(2,2)=1.5;
coord(3,1)=-1.6;
coord(3,2)=1.8;
coord(4,1)=0;
coord(4,2)=2.7;
coord(5,1)=1.6;
coord(5,2)=1.8;
coord(6,1)=0.9;
coord(6,2)=1.5;
coord(7,1)=0.6;
coord(7,2)=0;
coord(8,1)=0;
coord(8,2)=1.5;
c(1,1)=1;
c(1,2)=2;
c(2,1)=2;
c(2,2)=3;
c(3,1)=3;
c(3,2)=4;
c(4,1)=4;
c(4,2)=5;
c(5,1)=5;
c(5,2)=6;
c(6,1)=6;
c(6,2)=7;
c(7,1)=7;
c(7,2)=8;
c(8,1)=1;
c(8,2)=8;
c(9,1)=2;
c(9,2)=4;
c(10,1)=4;
c(10,2)=8;
c(11,1)=4;
c(11,2)=6;
c(12,1)=2;
c(12,2)=8;
c(13,1)=6;
c(13,2)=8;
%c=int8(c);
m=zeros(13,13);
for i=1:13
   if c(i,1)~=1
   	if c(i,1)==8
      	dist=((coord(c(i,1),1)-coord(c(i,2),1))^2+(coord(c(i,1),2)-coord(c(i,2),2))^2)^0.5;
      	m(12,i)=(coord(c(i,1),1)-coord(c(i,2),1))/dist;
      	m(13,i)=(coord(c(i,1),2)-coord(c(i,2),2))/dist;
   	elseif c(i,1)==7
      	dist=((coord(c(i,1),1)-coord(c(i,2),1))^2+(coord(c(i,1),2)-coord(c(i,2),2))^2)^0.5;
         m(11,i)=(coord(c(i,1),1)-coord(c(i,2),1))/dist;
      else
         dist=((coord(c(i,1),1)-coord(c(i,2),1))^2+(coord(c(i,1),2)-coord(c(i,2),2))^2)^0.5;
      	m(2*c(i,1)-3,i)=(coord(c(i,1),1)-coord(c(i,2),1))/dist;
      	m(2*c(i,1)-2,i)=(coord(c(i,1),2)-coord(c(i,2),2))/dist;
   	end
   end
   if c(i,2)~=1
      if c(i,2)==8
      	dist=((coord(c(i,1),1)-coord(c(i,2),1))^2+(coord(c(i,1),2)-coord(c(i,2),2))^2)^0.5;
      	m(12,i)=(coord(c(i,2),1)-coord(c(i,1),1))/dist;
         m(13,i)=(coord(c(i,2),2)-coord(c(i,1),2))/dist;
      elseif c(i,2)==7
      	dist=((coord(c(i,1),1)-coord(c(i,2),1))^2+(coord(c(i,1),2)-coord(c(i,2),2))^2)^0.5;
      	m(11,i)=(coord(c(i,2),1)-coord(c(i,1),1))/dist;
      else
         dist=((coord(c(i,1),1)-coord(c(i,2),1))^2+(coord(c(i,1),2)-coord(c(i,2),2))^2)^0.5;
         m(2*c(i,2)-3,i)=(coord(c(i,2),1)-coord(c(i,1),1))/dist;
         m(2*c(i,2)-2,i)=(coord(c(i,2),2)-coord(c(i,1),2))/dist;
      end
   end
end
m
b=zeros(13,1);
b(4,1)=-10;
b(8,1)=-15;
b
m\b

