function [X,Y]=fnsplin(x,y)
% Naturliga kubiska splines
  n=length(x);  h=diff(x);  dy=diff(y);
  dia=2*([h; 0]+[0; h]); 
  hf=h(1:n-2);   hs=h(2:n-1); 
  p=[h(1); hf];  q=[hs; h(n-1)];             
  b=3*[dy(1); hf./hs.*dy(2:n-1)+hs./hf.*dy(1:n-2); dy(n-1)];   
  k=tridia(dia,p,q,b);
  g=h.*k(1:n-1)-dy; c=2*dy-h.*(k(1:n-1)+k(2:n));
  X=x(1); Y=y(1);
  dt=0.05; t=(dt:dt:1)'; 
  for i=1:n-1
    X=[X; x(i)+t*h(i)];  
    Y=[Y; y(i)+t*dy(i)+t.*(1-t)*g(i)+t.^2.*(1-t)*c(i)];
  end
%.................................................................




