clear all

x = [0  4    8    12   16   20 ] ;
y = [2 4.93 6.38 6.37 4.88 1.91] ;
n = 6 ;

A = [  n       sum(x)    sum(x.^2) ;
     sum(x)    sum(x.^2) sum(x.^3) ;
     sum(x.^2) sum(x.^3) sum(x.^4) ] ;

b = [sum(y) ; sum(x.*y) ; sum(x.^2.*y)] ;

a = A \ b

xq = 0:0.1:22 ;
yq = a(1)+a(2)*xq+a(3)*xq.^2 ;

plot (xq , yq) ; axis equal ; grid on ;