The Predator-Prey Equation in Matlab
来源:互联网 发布:exshop建站 编辑:程序博客网 时间:2024/04/28 06:05
转载自:http://www-users.math.umd.edu/~jmr/246/predprey.html
The Predator-Prey Equation
Contents
- Original Lotka-Volterra Model
- Critical points:
- Phase Plot
- Plot of Populations vs. Time
- Modified Model with "Limits to Growth" for Prey (in Absence of Predators)
- Critical points:
- Plot of Populations vs. Time
Original Lotka-Volterra Model
We assume we have two species, herbivores with population x, and predators with propulation y. We assume that x grows exponentially in the absence of predators, and that y decays exponentially in the absence of prey. Consider, say, the system
Critical points:
syms x yvars = [x, y];eqs = [x*(1-y/2), y*(-1+x/2)];[xc, yc] = solve(eqs(1), eqs(2));[xc, yc]A = jacobian(eqs, vars);disp('Matrix of linearized system:')subs(A, vars, [xc(1), yc(1)])disp('eigenvalues:')eig(ans)disp('Matrix of linearized system:')subs(A, vars, [xc(2), yc(2)])disp('eigenvalues:')eig(double(ans))
ans = [ 0, 0][ 2, 2] Matrix of linearized system: ans = [ 1, 0][ 0, -1] eigenvalues: ans = 1 -1 Matrix of linearized system: ans = [ 0, -1][ 1, 0] eigenvalues:ans = 0 + 1.0000i 0 - 1.0000i
Thus we have a center at (2, 2) and a saddle point at (0, 0), at least for the linearized system. This suggests the possibility of periodic orbits centered around (2, 2).
Phase Plot
rhs1 = @(t, x) ... [x(1)*(1-.5*x(2)); x(2)*(-1+.5*x(1))];options = odeset('RelTol', 1e-6);figure, hold onfor x0 = 0:.2:2 [t, x] = ode45(rhs1, [0, 10], [x0;2]); plot(x(:,1), x(:,2))end, hold off
Plot of Populations vs. Time
We color-code the plots so you can see which ones go together.
colors = 'rgbyc';figure, hold onfor x0 = 0:10 [t, x] = ode45(rhs1, [0, 25], [x0/5; 2], options); subplot(2, 1, 1), hold on plot(t, x(:,1), colors(mod(x0,5)+1)) subplot(2, 1, 2), hold on plot(t, x(:, 2), colors(mod(x0,5)+1)) hold onendsubplot(2, 1, 1)xlabel tylabel 'x = prey'subplot(2, 1, 2)xlabel tylabel 'y = predators'hold off
Modified Model with "Limits to Growth" for Prey (in Absence of Predators)
In the original equation, the population of prey increases indefinitely in the absence of predators. This is unrealistic, since they will eventually run out of food, so let's add another term limiting growth and change the system to
Critical points:
syms x yvars = [x, y];eqs = [x*(1-y/2-x/4), y*(-1+x/2)];[xc, yc] = solve(eqs(1), eqs(2));[xc, yc]A = jacobian(eqs, vars);disp('Matrix of linearized system:')subs(A, vars, [xc(1), yc(1)])disp('eigenvalues:')eig(ans)disp('Matrix of linearized system:')subs(A, vars, [xc(2), yc(2)])disp('eigenvalues:')eig(ans)disp('Matrix of linearized system:')subs(A, vars, [xc(3), yc(3)])disp('eigenvalues:')eig(double(ans))
ans = [ 0, 0][ 4, 0][ 2, 1] Matrix of linearized system: ans = [ 1, 0][ 0, -1] eigenvalues: ans = 1 -1 Matrix of linearized system: ans = [ -1, -2][ 0, 1] eigenvalues: ans = -1 1 Matrix of linearized system: ans = [ -1/2, -1][ 1/2, 0] eigenvalues:ans = -0.2500 + 0.6614i -0.2500 - 0.6614i
Thus we have saddles at (0, 0), (4, 0) and a stable spiral point at (2, 1).
rhs2 = @(t, x) ... [x(1)*(1-.5*x(2)-0.25*x(1)); x(2)*(-1+.5*x(1))];figure, hold onfor x0 = 0:.2:2 [t, x] = ode45(rhs2, [0, 10], [x0;1]); plot(x(:,1), x(:,2))endfor x0 = 0:.2:2 [t, x] = ode45(rhs2, [0, -10], [x0;1]); plot(x(:,1), x(:,2))endaxis([0, 4, 0, 4]), hold off
Warning: Failure at t=-3.380660e+000. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (7.105427e-015) at time t.Warning: Failure at t=-3.535072e+000. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (7.105427e-015) at time t.Warning: Failure at t=-3.735844e+000. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (7.105427e-015) at time t.Warning: Failure at t=-3.984664e+000. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (7.105427e-015) at time t.Warning: Failure at t=-4.299922e+000. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.421085e-014) at time t.Warning: Failure at t=-4.719481e+000. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.421085e-014) at time t.Warning: Failure at t=-5.332082e+000. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.421085e-014) at time t.Warning: Failure at t=-6.437607e+000. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.421085e-014) at time t.
Plot of Populations vs. Time
figure, hold onfor x0 = 0:20 [t, x] = ode45(rhs2, [0, 25], [x0/5; 1], options); subplot(2, 1, 1), hold on plot(t, x(:,1), colors(mod(x0,5)+1)) subplot(2, 1, 2), hold on plot(t, x(:, 2), colors(mod(x0,5)+1)) hold onendsubplot(2, 1, 1)xlabel tylabel 'x = prey'subplot(2, 1, 2)xlabel tylabel 'y = predators'hold off
- The Predator-Prey Equation in Matlab
- The equation
- sgu 106 The equation
- SGU 106 The equation
- The equation----扩展欧几里得
- [SGU]106. The Equation
- sgu 106 The equation
- hdu3270 The Diophantine Equation
- UVa10326 - The Polynomial Equation
- sgu The equation
- 106. The equation
- SGU 106 The equation
- SGU 106 The equation
- SGU 106 The equation
- SGU106 The equation
- SGU106 The equation
- SGU106 The equation(数论)
- SGU 106 The equation
- Quick Search Box for Windows 停止开发,如何单独安装之?
- 昨天去exoweb的复试感受,及其中一题的部分仅供看下的答案
- 记录记录
- 定制CentOS光盘
- asp.net如何去掉HTML标记
- The Predator-Prey Equation in Matlab
- jboss5 包冲突 java.lang.LinkageError: loader constraint violation
- Java.io.File类学习笔记
- MFC内部运行来龙去脉追踪
- 受管制的代码和强类型系统
- 如何在没有栈的情况下利用堆分析crash文件
- M/M/n stochastic queueing equations in Matlab
- 企业IT部门的职责和定位(转)
- utf-8编码下 在火狐和ie里处理不一致问题(火狐 网页 utf-8 空格)