% intpolklick,  interpolation med växande gradtal på polynomet
  clear, clf
  axis([0 100 0 80]), hold on
  disp(['Klicka punkter (bryt med mittknappen)'])
  x=[]; y=[]; 
  farg='rmbcgyrmbcgyrmb'; fig='.ox+*sdv^<>ph.o';
  for i=1:15
    [xp,yp,button]=ginput(1);  
    if button==2, break
    else plotus(xp,yp,fig(i)), x=[x; xp]; y=[y; yp]; end
  end, n=length(x);
  [x,I]=sort(x);  y=y(I); dx=diff(x);  % sortera   

% öka polynomets gradtal successivt
  xi=x(1); yi=y(1); dt=0.05; t=(dt:dt:1)'; X=x(1); 
  for i=2:n              
    title(['Polynom av grad ', int2str(i-1)])             
    xi=[xi; x(i)]; yi=[yi; y(i)]; 
    Ak=ones(i,1); A=Ak; 
    for kol=2:i, Ak=Ak.*(xi-xi(kol-1)); A=[A Ak]; end
    c=A\yi;
    X=[X; x(i-1)+dx(i-1)*t];
    Y=zeros(size(X));  for k=i:-1:1, Y=Y.*(X-xi(k))+c(k); end
    plotus(X,Y,farg(i)),  pause(1)
  end
  [Xs,Ys]=fnsplin(x,y);  plotus(Xs,Ys,'k-.') % naturliga kub.splines



