% This is the main function to solve % dN/dt = KN in p.117, Mathematical Models in Biology global K K = 1; % rate of reproduction per unit time options = odeset('RelTol',1e-4,'AbsTol',1e-4); t0 = 0; tfinal = 3; N_ini = 5; [T,N] = ode45(@bacterialgrowth,[t0 tfinal],N_ini,options); % plot N at different T plot(T,N) xlabel t, ylabel N % plot exact solution Nexact = N_ini*exp(K*T); figure(2) plot(T,Nexact,'r') xlabel t, ylabel('exact solution of N')