clear all; close all; clc;
%% example for least squares

%% data
d1 = [0 2];
d2 = [-1 5];
d3 = [-2 4];

%% 1st column is t value
%% 2nd column is y value
data_vec = [d1; d2; d3];
figure(1)
plot(data_vec(:,1), data_vec(:,2),'bo','markersize',10, 'linewidth', 5); hold on
set(gca,'fontsize', 20)

pause

A = [0 0 1; 1 -1 1; 4 -2 1];
b = [2; 5; 4];

xstar = A \ b;
tvec = linspace(-2, 2, 100);
parabola = @(t) xstar(1).*t.^2 + xstar(2).*t + xstar(3);
plot(tvec, parabola(tvec), 'r', 'linewidth', 4);

