function [estimates,model] = fitcurvedemo(xdata,ydata)
start_point = rand(1,2);
model = @expfun;
estimates = fminsearch(model,start_point);

    function [sse,FittedCurve] = expfun(params)
        A = params(1);
        lambda = params(2);
        FittedCurve = A.*exp(-lambda*xdata);
        ErrorVector = FittedCurve-ydata;
        sse = sum(ErrorVector.^2);
    end
end
