%
% MONOD MODEL FITTING EXAMPLE
%
% Bob Newell, January 1996
%
%-------------------------------------------------
%
global mudat
global sdat
global yhat
global test
%
%---------------------------------------------
% first generate some simulated data
%
% the true parameters
muhat = 5;
ksat = 30;
% the substrate and rate data
s = 5:100;
mu = muhat * s ./ ( ksat + s );
% add some Normally distributed noise
n1 = randn( size(s) );
n2 = randn( size(s) );
mudat = mu + 0.025 * mean( mu ) * n1;
sdat = s + 0.025 * mean( s ) * n2;
%---------------------------------------------
% plot data in nonlinear and linear forms
%
figure
plot( sdat, mudat, '+' )
set( gca, 'fontsize', 24 );
xlabel( 'Substrate' )
ylabel( 'Rate' )
figure
plot( mudat./sdat, mudat, '+' )
set( gca, 'fontsize', 24 );
xlabel( 'Rate / Substrate' )
ylabel( 'Rate' )
%---------------------------------------------
% now a linear fit of the transformed data
%
[ p, h ] = linreg( mudat, (-mudat./sdat), sdat );
% add blob for the true values
figure( h(5) );
hold on
ax = axis;
blobx = 0.020 * ( ax(2) - ax(1) );
bloby = 0.025 * ( ax(4) - ax(3) );
xblob = blobx * [ 1 0 -1 0 ]' + muhat;
yblob = bloby * [ 0 -1 0 1 ]' + ksat;
fill( xblob, yblob, 'k' )
hold off
%-------------------------------------------------
% now for the nonlinear bit
%
po = [ 4 20; 4 40; 6 20; 6 40 ];
[ p, r, h ] = nlreg( mudat, sdat, po, ax, 'Monod_Function' );
% add blob for the true values
figure( h(5) );
hold on
ax = axis;
blobx = 0.020 * ( ax(2) - ax(1) );
bloby = 0.025 * ( ax(4) - ax(3) );
xblob = blobx * [ 1 0 -1 0 ]' + muhat;
yblob = bloby * [ 0 -1 0 1 ]' + ksat;
fill( xblob, yblob, 'k' )
hold off
%-------------------------------------------------------
print -f1 -deps2 ex7-1a.eps
print -f2 -deps2 ex7-1b.eps
print -f4 -deps2 ex7-3b.eps
print -f6 -deps2 ex7-3a.eps
print -f7 -deps2 ex7-4.eps
print -f9 -deps2 ex7-6b.eps
print -f11 -deps2 ex7-6a.eps
print -f12 -deps2 ex7-6c.eps
%
% thats all folks
