## Function that fits a given set of data point to a polynomial of
## specified degree, producing at the same time a superimposed plot of the
## data points and the fit.
## Usage p=fit(x,y,n)

function p=fit(x,y,n)

  p=polyfit(x,y,n);
  xx=linspace(min(x),max(x),100);
  plot(x,y,'b*;Data;',x,polyval(p,xx),'r-;Fit;');
  
endfunction

