Example 1: Start with 1200 coyotes and 500 roadrunners. What will happen in the long run --- that is over many generations? >> A = [ 0.86 0.08; -0.12 1.14] >> P = [ 1200; 500] >> M = P >> for i = 1:10 P = A*P; M(:,i+1) = P; end gives the first 11 generations of the evolving populations (in thousands): 1.0e+03 * Columns 1 through 7 1.2000 1.0720 0.9560 0.8507 0.7550 0.6678 0.5881 0.5000 0.4260 0.3570 0.2923 0.2311 0.1728 0.1169 Columns 8 through 11 0.5151 0.4480 0.3861 0.3286 0.0627 0.0097 -0.0428 -0.0951 Both populations die out. We can plot our results. The transpose matrix M holds the coyote populations in its first column and the roadrunner populations in its second column. If we type >> plot(M') we will get a plot of the coyote and roadrunner populations versus time (represented by the row index of M' or the column index of M). To plot coyote population versus roadrunner population we want to plot the first row of M versus the second row of M: >> plot(M(1,:), M(2,:)) >> axis equal >> hold on % if we want to add more plots later. % when we are done we type hold off Example 2: If we start with P = [2000;1200] then how do the populations change over time? Looking at the first 25 generations we get (again in thousands): Columns 1 through 7 2.0000 1.8160 1.6520 1.5062 1.3768 1.2626 1.1621 1.2000 1.1280 1.0680 1.0193 0.9812 0.9534 0.9354 Columns 8 through 14 1.0742 0.9980 0.9325 0.8770 0.8308 0.7933 0.7642 0.9269 0.9277 0.9378 0.9572 0.9860 1.0244 1.0726 Columns 15 through 21 0.7430 0.7295 0.7234 0.7246 0.7330 0.7486 0.7716 1.1310 1.2002 1.2807 1.3732 1.4785 1.5975 1.7313 Columns 22 through 26 0.8021 0.8403 0.8865 0.9411 1.0046 1.8811 2.0482 2.2341 2.4405 2.6692 Initially, both populations decline but around generation 8 a recovery begins. After 100 generations we will find 1.1 million coyotes and 3.3 million road runners. Example 3: If we start with P = [ 2000; 1000 ] and look at the first 20 generations: >> P = [2000;1000], M = P >> for i = 1:20 P = A*P; M(:,i+1) = P; end Again our results (in thousands) is: Columns 1 through 7 2.0000 1.8000 1.6200 1.4580 1.3122 1.1810 1.0629 1.0000 0.9000 0.8100 0.7290 0.6561 0.5905 0.5314 Columns 8 through 14 0.9566 0.8609 0.7748 0.6974 0.6276 0.5649 0.5084 0.4783 0.4305 0.3874 0.3487 0.3138 0.2824 0.2542 Columns 15 through 21 0.4575 0.4118 0.3706 0.3335 0.3002 0.2702 0.2432 0.2288 0.2059 0.1853 0.1668 0.1501 0.1351 0.1216 If we continue, we find that after 100 generations we will have about 60 coyotes and 30 roadrunners. After 120 generations we will have 6 coyotes and 3 roadrunners. Eventually, both populations die out. To graph several of these curves together we could use the following sequence of MATLAB commands: A = [0.86 0.08; -0.12 1.14] % define the transition matrixf P = [1200;500]; % set up the initial population vector M = P; for i = 1:25 % Look at how P changes over 25 generations P = A*P; % store the results for the ith generation M(:,i+1) = P; % in the i+1 column of the matrix M end plot(M(1,:), M(2,:)) % plot coyote versus roadrunner pops axis equal hold on % we want to add more curves to this plot P = [2000; 1200]; N = P; for i = 1:25 P = A*P; % repeat for initial population = [2000,1200] N(:,i+1) = P; end plot(N(1,:), N(2,:)) P = [ 500; 1700]; R = P; for i = 1:12 P = A*P; % repeat for initial population = [500, 1700] R(:,i+1) = P; end plot(R(1,:), R(2,:)) hold off