function polynomialniRegrese(n,m)

x = rand(m,1);
y = 0.1*(-0.5+rand(m,1))+x-x.^2;

A = zeros(m,n+1);
for i=1:m
    for j=1:n+1
        A(i,j) = x(i)^(j-1);
    end
end
alfa = (A'*A) \ (A'*y);

xx = 0:0.01:1;
yy = xx; yy(:) = 0;
for i=1:n+1
    yy = yy + alfa(i)*xx.^(i-1);
end
plot(x,y,'k*',xx,yy,'r',xx,xx-xx.^2,'b')