clear; clc; close all;

n = 10;
x = linspace(0, 1, n);
% y = @(x) sin(x + randn(1)) .* exp(x);
y = rand(1) + 0.5 * cos(10 * x) + x;

figure;
plot(x, y, 'o'); hold on; grid on;

A = [x', ones(n, 1)];
b = y';
coeff = A \ b
x_new = linspace(0, 1, 30);
y_new = coeff(1) * x_new + coeff(2);
plot(x_new, y_new, '--'); 