clear; clc; close all;

N = 10;
x0 = linspace(0, 1, N)';
x_range = linspace(-0.1, 1.1, 100);
y0 = rand() + 0.5 * cos(10* x0) + x0;

figure; hold on; grid on;
plot(x0, y0, 'o');
% A = [x0, ones(N, 1)]; % linear equation
% A = [x0 .^ 2, x0, ones(N, 1)]; % quadratic equation
A = [x0 .^ 3, x0 .^ 2, x0, ones(N, 1)]; % cubic equation
coeff = A \ y0;
plot(x_range, polyval(coeff, x_range), 'r--');
