function Ke = Stiffness(n,E,nu,t,conn,coord)

%  Set up elastic matrix

D = E/(1-nu^2)*[ 1 nu 0
                 nu 1 0
                 0  0 (1-nu)/2];

%  Unpack node numbers and nodal coordinates

n1 = conn(n,1);
n2 = conn(n,2);
n3 = conn(n,3);

x1 = coord(n1,1);
y1 = coord(n1,2);
x2 = coord(n2,1);
y2 = coord(n2,2);
x3 = coord(n3,1);
y3 = coord(n3,2);

%  Calculate B matrix

A = det( [ 1 x1 y1
            1 x2 y2
            1 x3 y3] ) /2;
b1 = y2-y3;
b2 = y3-y1;
b3 = y1-y2;
a1 = x3-x2;
a2 = x1-x3;
a3 = x2-x1;

B = [ b1  0  b2  0  b3  0
       0 a1   0 a2   0 a3
      a1 b1  a2 b2  a3 b3 ]/ (2*A);

%  Calculate Stiffness Matrix

D = A*t*D;

Ke = B' * D * B;

%  That's all, folks.