function N=population(A,N0,T,maxN) % function N=population(A,N0,T,maxN) % % A is a parameter vector to be passed on to ratefnc. % % This function calculates the population up to time T % for the differential equation N'=ratefnc(N) with N_0=N0. % % maxN is the largest value of N for the plots. % define the parameters R = A(1); K = A(2); % compute the population values using Matlab's standard ODE solver. trange=[0 T]; [t,N] = ode45(@ratefnc,trange,N0); % plot the computed points (t,N) as a smooth curve. Set the axis ranges and labels. plot(t,N) xlim([0,T]) ylim([0,maxN]) xlabel('\it{t}','FontSize',12) ylabel('\it{N}','FontSize',12,'Rotation',0) % the code that follows is used to compute the new population levels % the parameters need to have been defined earlier function f=ratefnc(t,N) f = R*N*(1-N/K); end end