Goal: Compare the cubic "not-a-knot" spline and interpolating polynomial for the same data.
Use 7-9 data points. Plot both the spline and the data used for it. For comparison, also plot the
interpolating polynomial through these points. Make your conclusion about which method results
in a better-looking curve.
Method: we'll use built-in Matlab routine spline for this purpose. It takes three arguments
x,y,t where (x,y) are data points and t are the points at which the spline is to be computed.
Typically, t is some vector suitable for plotting, e.g., generated with linspace.
x = ...
y = ...
plot(x,y,'r*')
hold on
% x-values of your data
% y-values of your data
% mark the points with red asterisks
t = linspace(min(x), max(x));
s = spline(x,y,t);
plot(t,s)
% the points for plotting curves
% evaluate cubic spline at points of t
% plot it
% proceed to compute and plot interpolating polynomial
% Use another color, such as magenta (m)
In a comment, state your observation about how the behavior of these two curves (blue and
magenta) is different.