Difference equations and Matlab (some working)

3.8k Views Asked by At

The difference equations below model the yearly populations of wolves and moose, measured in hundreds. The wolves kill the moose for food.

$$\begin{align} x_n&=x_{n-1}-0.004x_{n-1}+0.002x_{n-1}y_{n-1}\\ y_n&=y_{n-1}+0.005y_{n-1}-0.010x_{n-1}y_{n-1}-0.001y_{n-1}^2 \end{align}$$

I think I've worked out what $x$ and $y$ are correctly.

$x_n$ is predator and $y_n$ is prey. I say this because the $x_n$ has a growth term

$$+ 0.002 x_{n-1}y_{n-1}$$

…which says that $x_n$ grows by interaction between $x$ and $y$. This is classic predation a.k.a. eating prey.

The $y$s have what looks like logistic growth:

$$y_{n-1} - 0.001y^2_{n-1}$$

which says this species has a population growth that is limited by the environment.

However, does anyone know what Matlab commands I would enter to answer this question?

If there are initially $50$ wolves and $300$ moose, use Matlab to obtain plot of $x$ and $y$ versus n on the same graph, for $0 \le n \le 10000$. Remember that $x$ and $y$ are measured in hundreds.

1

There are 1 best solutions below

10
On BEST ANSWER

You can simply write it in this way:

 x(1) = 50;
 y(1) = 200;
 for n=2:10001
      x(n) = x(n-1) - 0.004*x(n-1) + 0.002*x(n-1)*y(n-1);
      y(n) = y(n-1) + 0.005*y(n-1) - 0.010*x(n-1)*y(n-1) - 0.001*(y(n-1))^2;
 end
 plot(1:10001,x);
 hold all;
 plot(1:10001,y);