clc
clear all
yearn=[1  2  3  4  5  6]+1994
nasdaqv=[751  1052  1291  1570  2192  4069]
n=length(yearn)
p=polyfit(yearn,nasdaqv,n-1)
xi=yearn(1):(yearn(n)+3-yearn(1))/1000:yearn(n)+3;
yi=polyval(p,xi);
figure(5)
plot(yearn,nasdaqv,'o','MarkerSize',8)
hold on
plot(xi,yi,'LineWidth',3,'Color','Red')
hold off
xlabel('Year');
ylabel('NASDAQ');
title('Extrapolation is an Inexact Science');
legend('Data points','Polynomial Interpolant');
yearn =

        1995        1996        1997        1998        1999        2000


nasdaqv =

         751        1052        1291        1570        2192        4069


n =

     6

Warning: Polynomial is badly conditioned. Add points with distinct X
         values, reduce the degree of the polynomial, or try centering
         and scaling as described in HELP POLYFIT.

p =

       1.3791       -13753  5.4858e+007 -1.0941e+011   1.091e+014  -4.352e+016