[x, y] = m2samplenoisydata();
np = length(x);

c = m2qrfit(x, y);
yfit = c(1)*1 ./x + c(2)*cos(x) + c(3)*exp(-x.*x/4);

plot(x, y, 'b.')

hold on

plot(x, yfit, 'r-')

grid on
legend('Noisy data', 'LSQ fit')
xlabel('x')
ylabel('y')
title('Least squares fit')
