% This script illustrates the difference between
% polynomial interpolation and least-squares fitting
clear all
clc
scrnsz = get(0, 'Screensize');
xi = linspace(-5,5,201);
eta = 1./(xi.^2+1);
figure('Position', [5 10 scrnsz(3)-5 scrnsz(4)-60])
plot(xi,eta,'LineWidth',2)
title(sprintf('Polynomial Interpolation: data function'));
figure('Position', [5 10 scrnsz(3)-5 scrnsz(4)-60])
PolynomialLSQ(21,20);
figure('Position', [5 10 scrnsz(3)-5 scrnsz(4)-60])
PolynomialLSQ(21,1);
figure('Position', [5 10 scrnsz(3)-5 scrnsz(4)-60])
PolynomialLSQ(21,7);
figure('Position', [5 10 scrnsz(3)-5 scrnsz(4)-60])
PolynomialLSQ(21,9);
figure('Position', [5 10 scrnsz(3)-5 scrnsz(4)-60])
PolynomialLSQ(21,11);