A Guide to MATLAB for Beginners and Experienced Users, Second Edition

We are going to look at two models for population growth of a species. The first is a standard exponential growth/decay model that describes quite well the population of a species becoming extinct, or the short-term behavior of a population growing in an unchecked fashion. The second, more realistic, model describes the growth of a species subject to constraints of space, food supply, and competitors/predators.
We assume that the species starts with an initial population P 0. The population after n time units is denoted P n. Suppose that, in each time interval, the population increases or decreases by a fixed proportion of its value at the beginning of the interval. Thus
The constant r represents the difference between the birth rate and the death rate. The population increases if r is positive, decreases if r is negative, and remains fixed if r = 0.
Here is a simple M-file that we will use to compute the population at stage n, given the population at the previous stage and the rate r.
<b class="bold">type itseq</b><b class="bold">function X = itseq(f, Xinit, n, r)</b><b class="bold">% Computes an iterative sequence of values.</b><b class="bold">X = zeros(n + 1, 1);</b><b class="bold">X(1) = Xinit;</b><b class="bold">for k = 1:n</b><b class="bold"> X(k + 1) = f(X(k), r);</b><b class="bold">end</b>
In fact, this is a simple program for computing iteratively the values of a sequence x k +1 = f (