function coeff=census_data(t,P)

%census_data takes in a vector 
x=length(t);  %Find out how many data points there are in the domain (note-Length for vectors, size for matrix)
mu=mean(t);     %Find mean of data points
sigma=std(t);   %Find standard deviation of data points

s=((t-mu)/sigma);   %calculate new variable for interpolatingdomain
x1=floor(s(1));     %get good lower bound for interpolating domain
x2=ceil(s(x));      %get good upper domain for interpolating domain

V=vander(s);        %compute vandermonde matrix for domain
c=V\P';             %calculate coefficients for interpolating polynomial

u=[x1:.1:x2];       %Interpolating domain
p=polyinterp(s,P,u);    

%Plotting and text to make plot and coefficients appear on the same viewing
%window

plot(s,P,'o',u,p,'-')
axis([s(1)-.2 s(x)+.2 min(P)-100 max(P)+100]);
xlabel('(t-\mu)/\sigma'); ylabel('Population (in Millons)'); 
title('U.S Census data for 1900-2000');

text(s(1), max(P)+80,'Coefficients for Interpolating','color','blue')
text(s(1)+.5,max(P)-30,num2str(c));
for i=0: 10
    text(s(1)+.15,max(P)+60-i*19,'c','color','blue');
    text(s(1)+.25,max(P)+60-i*19,num2str(i),'color','blue');
end



