%filename:sim.m
% Simple Exponential Growth Abrupt Cut-off
% W + S = Wo + So = Wf + Sf
% No lose / no gain
% Wo is the initial weight,Wf is the final weight.
% So is the initial substrate,Sf is the final substrate.
% dW/dt = mu*W, mu is the growth rate and it is around 0.008.
global mu Wo So tf 

data;
tf = (log((Wo + So)/Wo)/mu);
Wf = Wo*exp(mu*tf);
Sf = Wo + So -Wf;

t0=0;

[t,W] =ode23('simf',t0,tf,Wo);

t = [t;tf+200];
W = [W;Wf];

subplot(2,1,1);plot(t,W,'b');
xlabel('t:time in days');
ylabel('W:weight in lbs');
title('Simple Exponential Growth with Abrupt Cut-off,LINEAR.');
grid;
subplot(2,1,2);plot(t,log(W),'b');
xlabel('t:time in days');
ylabel('W:weight in lbs');
title('Simple Exponential Growth with Abrupt Cut-off,SEMILOG.');
grid;

%Save the figure into GIF file.
% print -dgif8 simexp
print -dpbm simexp.pbm
%print simexp.ps
%Save output into HTML file.
fprintf('<HTML>');
fprintf('\n<HEAD>');
fprintf('\n<TITLE>output</TITLE>');
fprintf('\n</HEAD>');
fprintf('\n<BODY BGCOLOR="#FFFFFF">');
fprintf('\n<H2>');
fprintf('\nThe outputs for the Simple Exponential Growth Abrupt');
fprintf(' Cut-off.');
fprintf('\n</H2>');
fprintf('\n<IMG SRC="simexp.gif"><P>');
fprintf('\nThe growth rate is %10.4f.<BR>',mu);
fprintf('\nThe final time is %10.4f.<BR>',tf);
fprintf('\nThe initial weight is %10.4f.<BR>',Wo);
fprintf('\nThe final weight is %10.4f.<BR>',Wf);
fprintf('\nThe initial substrate is %10.4f.<BR>',So);
fprintf('\n</BODY>');
fprintf('\n</HTML>');

