%
% M file demonstrating the use of NLSQ_ERR solver for
% nonlinear least squares problems
%

%  Initialize problem
[ fobs, fwght, x0, options, uds] = Enzyme;

%  Plot data and initial guess
uds.fobsi = fobs;
uds.fmodi0 = Enzyme( x0, '', uds);
plot(uds.ti,uds.fobsi,'bd', ...
    uds.ti,uds.fmodi0,'g-');
hold on;

%  Set some method option
options.xtol = 1.e-5;
options.kmax = 50;
options.printmon = 2;
options.printsol = 1;
options.fid = 1;
options.numdif = 0;
options.lambda0 = 0.01;
options.lambdamin = 0.0001;
options.ftol = 1.e-5;


%  Call solver
   [xstar, info] = NLSQ_ERR( 'Enzyme', fobs, fwght, x0, uds, options);
   
%  Plot final model values  
uds.fmodistar = Enzyme( xstar, '', uds);  

plot(uds.ti,uds.fmodistar,'r-');
title('Enzyme reaction problem: date, initial guesss and solution');
xlabel('t');
ylabel('f');
   
