% Script file showing the example in the text % First, get the data points numpts=10; x=linspace(-5,5,numpts)'; %Column vector of data t=linspace(-5,5,150); %For plotting y=1./(1+x.^2); %Column vector of desired output yt=1./(1+t.^2); %For plotting V=vander(x); a=V\y; %Test the polynomial on the new data in t yout=polyval(a,t); %This is to evaluate the polynomial whose coeffs in vector a plot(x,y,'k*',t,yt,'k-',t,yout,'m-');