function c = fitPol(x,y,n)
m = length(x);
a = min(x);
b = max(x);
z = (2*x-a-b)/(b-a);
T = ones(n+1,m);
T(2,:) = z;
for i = 3:n+1
    T(i,:) = 2*z.*T(i-1,:)-T(i-2,:);
end
A = T*T';
b = T*y';
c = A\b;
