% another matlab script to demonstrate the polyinterp function
% this time we note a shortcoming of high-degree polynomial interpolation

close all
clear all

% create the data set
x_k = 1:6;
y_k = [16 18 21 17 15 12];
disp([x_k; y_k])

% create the grid and evaluate the interpolant on it
x = 0.75:0.05:6.25;
y = polyinterp(x_k,y_k,x);

% plot the results
plot(x_k,y_k,'o',x,y,'-');

% notice the oscillations!