function builtin_fit_check(x,y, fitobject)

% fitted values at given x
yf=feval(fitobject,x);
res=y-yf;

disp('comparing data and fit');

figure(1)
subplot(2,1,1)
hold off;
plot(x,y,'.');
hold on; 
plot(fitobject, 'r-');
legend('data','fit');

subplot(2,1,2)
hold off;
plot(x,res,'x');  % plotting residuals
hold on;
plot(x,x*0, 'k-'); % this will plot a line along x axis
legend('residuals');
xlabel('x'); ylabel('residuals');
hold off;
