function p = polyfit_fast(x,y,n)
%% p = polyfit_fast(x,y,n)
% Fit n'th degree polynomial to x,y data without any condition checks.

x = x(:); y = y(:);

% Construct Vandermonde matrix
V(:,n+1) = ones(length(x),1,class(x));
for j = n:-1:1
   V(:,j) = x.*V(:,j+1);
end

p = V\y; % Solve least squares problem

p = p.';
end