function [coeffs, condest] = vandinterp(xdata,ydata)
% Compute coeffs of interpolation polynomial to xdata,ydata
% Uses Vandermonde matrix, returns also conition estimate.
%
% Note: coeffs: from high to low 
% a(1)x^n + a(2)x^(n-1)+...+a(n-1)x +a(n)
% Example
% xdata = 0:5; ydata = xdata.*sin(xdata);
% [c coeffs] = vandinterp(xdata,ydata);
x = xdata(:); y = ydata(:);  % Make column vectors
V = vander(x); % Matlab's own.
% How to form yourself?
% N=length(xdata);V=ones(N,N); 
% for k=1:N-1, V(:,k+1)=x.*V(:,k),end
% V=fliplr(V);
condest = cond(V);
coeffs = V\y;
