%% Get some data together x=rand(13,1); x=sort(x); y=2*randn(size(x)); plot(x,y,'.') t=linspace(0,1); % 100 evenly spaced points between 0 and 1 %% Form the Vandermonde matrix (starting with the highest power in the first column) vv=vander(x'); % Find the polynomial coefficients by just inverting the Vandermonde matrix c1=inv(vv)*y; y1=polyval(c1,t); %Evaluate the polynomial using coefficients in c1 on data in t. hold on plot(t,y1,'k-'); %Plot the result %axis([0 1 -40 40]) %Probably need to re-scale [U,S,V]=svd(vv); %Let's see what happens with the pseudo inverse. c5=V(:,1:8)*diag(1./diag(S(1:8,1:8)))*U(:,1:8)'*y y2=polyval(c5,t); plot(t,y2,'r-'); hold off