% matlab script to demonstrate the construction of a
% Vandermonde system and its solution

close all
clear all

% create data set
x = 0:3
y = [-5 -6 -1 16]

% view them as a table
disp([x; y])

% we want to find the coefficients of the polynomial in power form
% that interpolates the data in this table

% to do this, we need to set up and solve a linear system

% the coefficient matrix is a Vandermonde matrix
% based on the x-data
A = vander(x)

% the right-hand side is the y-data
b = y'

% solve the system to get the required coefficients
c = A\b