clear; clc; close all;

rng(3);
N = 10;
x = linspace(0, 1, N); 
x = x(:);
y = cos(rand(size(x)) * pi / 2) + x .^ 2;
figure; hold on; grid on;
plot(x, y, 'o');

eps = 0.05;
x_range = linspace(0 - eps, 1 + eps, 100);
for i = 1 : 8
    p = polyfit(x, y, i);
    y_ = polyval(p, x_range);
    plot(x_range, y_);
end



