clear all; close all;

xdata = (0:.1:10)';
ydata = 40 * exp(-.5 * xdata) + randn(size(xdata));

[estimates,model] = fitcurvedemo(xdata,ydata)

plot(xdata,ydata,'*')
hold on
[sse,FittedCurve] = model(estimates);
plot(xdata,FittedCurve,'r');
xlabel('xdata')
ylabel('f(estimates,xdata)')
title(['Fitting to function ',func2str(model)])
legend('data',['fit using ',func2str(model)])
hold off