%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 
file1 = fopen('outputs.html','w');

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 -dpsc simexp
%print simexp.ps
%Save output into HTML file.
fprintf(file1,'<HTML>');
fprintf(file1,'\n<HEAD>');
fprintf(file1,'\n<TITLE>output</TITLE>');
fprintf(file1,'\n</HEAD>');
fprintf(file1,'\n<BODY BGCOLOR="#FFFFFF">');
fprintf(file1,'\n<H2>');
fprintf(file1,'\nThe outputs for the Simple Exponential Growth Abrupt');
fprintf(file1,' Cut-off.');
fprintf(file1,'\n</H2>');
fprintf(file1,'\n<IMG SRC="warner-bin/simexp.gif"><P>');
fprintf(file1,'\nThe growth rate is %10f.<BR>',mu);
fprintf(file1,'\nThe final time is %10f.<BR>',tf);
fprintf(file1,'\nThe initial weight is %10f.<BR>',Wo);
fprintf(file1,'\nThe final weight is %10f.<BR>',Wf);
fprintf(file1,'\nThe initial substrate is %10f.<BR>',So);
fprintf(file1,'\n</BODY>');
fprintf(file1,'\n</HTML>');
close = fclose(file1);

