Consider the data points In MATLAB a) Find a single polynomial that interpolates
ID: 665338 • Letter: C
Question
Consider the data points
In MATLAB
a) Find a single polynomial that interpolates the data points
b) Check with a plot that your polynomial does indeed interpolate the data. You
can use matlab commad polyval to evaluate a polynomial given the coecients.
c) Would this interpolating polynomial likely give a good prediction of what is
happening at x = 1.5? Why or why not?
d) Create a cubic spline function for the same data, and plot it on the same graph
as the single polynomial interpolant. Does it do a better job describing the data?
Explanation / Answer
load census; f = fit(cdate, pop, 'linearinterp') plot(f,cdate,pop) load carbon12alpha f1 = fit(angle, counts, 'nearestinterp') f2 = fit(angle, counts, 'pchip') p1 = plot(f1, angle, counts) xlim( [min(angle), max(angle)]) hold on p2 = plot(f2, 'b') hold off legend([p1; p2], 'Counts per Angle','Nearest', 'pchip')