clear; clc; close all;

% set the data.  Here I chose to put it in a matrix, but we could use two
% vectors instead...
data = [
   0  4.579
   20 17.535
   40 55.324
   60 149.38
   70 233.7
   80 355.1
   85 433.6
   90 525.76
   95 633.9
   98 707.27
   100 760
   101 787.57 ];

% It will be a bit easier to use T and p rather than
% slicing the data array each time we need it.
T = data(:,1);
p = data(:,2);

% set the number of points in the data set.
npts = length(T);

% build our coefficient matrix.  If we are building a polynomial to
% interpolate all of the data points, then it will be an n-1 order
% polynomial.
A = zeros(npts);

% set up the matrix.
ncol = npts-1;
for i=0:ncol
  A(:,i+1) = T.^i;
end

% solve for the polynomial coefficients
% recall these are ordered a0 a1 ... an, where
%   y = a0 + a1x + a2x^2 + ... anx^n.
coefs = A\p;

% now we could evaluate the polynomial to obtain the interpolated values.
% This would require a loop over each polynomial coefficient to calculate
% each term in the summation (see class notes)...
