Matlab code please

Although the model in Prob. 22.4 works adequately when population growth is unlimited, it breaks down when factors such as food shortages, pollution, and lack of space inhibit growth. In such cases, the growth rate is not a constant, but can be formulated as \[ k_{g}=k_{g m}\left(1-\frac{p}{p_{\max }}\right) \] where $\mathrm{kgm}$ is the maximum growth rate under unlimited conditions, p=population, and pmax is the maximum population. Note that pmax is sometimes called the carrying capacity. Thus, at low population density $p \ll p m a x, k g \rightarrow k g m$. As $p$ approaches pmax, the growth rate approaches zero. Using this growth rate formulation, the rate of change of population can be modeled as \[ \frac{d p}{d t}=k_{g m}\left(1-\frac{p}{p_{\max }}\right) p \] This is referred to as the logistic model. The analytical solution to this model is \[ p(t)=p_{0} \frac{p_{\max }}{p_{0}+\left(p_{\max }-p_{0}\right) e^{-k_{g m}\left(t-t_{0}\right)}} \] Simulate the world's population from 1950 to 2050 using (a) the analytical solution, and (b) the fourth-order RK method with a step size of 5 years. Employ the following initial conditions and parameter values for your simulation: p0 $($ in 1950) $=2,560$ million people, $\mathrm{kgm}=0.026 / \mathrm{yr}$, and pmax $=12,000$ million people. Plot both the analytic and numerical solutions in the same plot.The second part must also incorporate this into the code:

[t,p] = rk4sys();

panalytic =

plot(t,p,t,panalytic, 'r-.')

legend('RK4', 'Analytic')

Public Answer

3QEEGV The First Answerer