function M=Masse(x)
  nq=length(x);nme=nq-1;
  h=x(2:nq)-x(1:(nq-1));
  M=sparse(nq,nq);
  for k=1:nme
    I=k:k+1;
    Mk=MasseElem(h(k));
    M(I,I)=M(I,I)+Mk;
  end  
end

function Me=MasseElem(hk)
  Me=(hk/6)*[2, 1; 1,2];
end
