forked from higham/matlab-guide-3ed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathharvest.m
More file actions
28 lines (23 loc) · 740 Bytes
/
harvest.m
File metadata and controls
28 lines (23 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function harvest
%HARVEST Predator-prey model with delay and harvesting.
tau = 9;
ic = [35; 10];
tspan = [0 250];
h = 10;
sol = dde23(@f,tau,ic,tspan);
subplot(2,1,1)
plot(sol.x,sol.y(1,:),'r-', sol.x,sol.y(2,:),'b--', 'LineWidth',2)
legend('y_1','y_2','Location','East')
title('h = 10'), xlabel t, ylabel('y','Rotation',0)
h = 15;
sol = dde23(@f,tau,ic,tspan);
subplot(2,1,2)
plot(sol.x,sol.y(1,:),'r-', sol.x,sol.y(2,:),'b--', 'LineWidth',2)
legend('y_1','y_2','Location','East')
title('h = 15'), xlabel t, ylabel('y','Rotation',0)
function v = f(t,y,Z)
%F Harvest differential equation.
v = [y(1)*(2*(1-y(1)/50) - y(2)/(y(1)+40)) - h
y(2)*(-3 + 6*Z(1)/(Z(1)+40))];
end
end