%* Matab script to calculate exponential decay, analytic soution
%
% variables set by user:
% lambda:     decay constant
% c0:         initial concentration
% t0:         initial time
% tmax:       end time
% h:          step size
%
% result:
% c:          vector containing concentration at all steps

clear

lambda=1;
t0=0;
tmax=5;
c0=1;
h=0.1;

%* analytic solution
t=[t0:h:tmax];%time vector
c=c0 * exp(-lambda*t);


%* plot cncentration over time
figure(1)
clf
axis([t0 tmax 0 1]), hold on
plot(t, c, 'r-')
title('exponential decay, decay const = 1')
xlabel('time'), ylabel('concentration')

