How to solve for a dependent system of difference (recursive) equations?

5 次查看(过去 30 天)
I have the following equations and I need help to solve this problem with MATLAB. I am brand new to MATLAB but I know I need 1 for loop to solve this.
I know my code is wrong, but this is what I have.
L(1) = 250;
P(1) = 5;
A(1) = 100;
cel = 0.012;
cea = 0.009;
cpa = 0.004;
ml = 0.267;
mp = 0;
ma = 0.0036;
b = 7.48;
x = linspace(1,1000);
for t=1:1000
L(t+1) = b*A(t)*exp(-cea*A(t)-cel*L(t));
P(t+1) = L(t)*(1-ml);
A(t+1) = P(t)*(1-mp)*exp(-cpa*A(t))+A(t)*(1-ma);
end
L(t)
P(t)
A(t)
plot(x,A(t+1))
And here are the equations/question:
L(t+1) = bA(t)exp((cea)A(t)(cel)L(t))
P(t+1) = L(t)(1 − µl)
A(t+1) = P(t)(1 − µp)exp((cpa)A(t)) + A(t)(1 − µa)
Use MATLAB to solve this system of difference equations with initial conditions L(0) = 250, P(0) = 5, A(0) = 100 and the following parameters: cel = 0.012, cea = 0.009, cpa = 0.004, µl = 0.267, µp = 0, µa = 0.0036, and b = 7.48. Plot the behavior of the adults and larvae under these control conditions and describe the baseline long-term behavior. Be sure you compute enough generations to be confident in your assessment of the long-term behavior.
Any help at all would be wonderful. Thank you!

采纳的回答

Star Strider
Star Strider 2016-9-15
You essentially got everything correct. You need to change the definition of ‘t’ in your loop index, and slightly restate the plot call arguments.
With a couple tweaks, it works:
L(1) = 250;
P(1) = 5;
A(1) = 100;
cel = 0.012;
cea = 0.009;
cpa = 0.004;
ml = 0.267;
mp = 0;
ma = 0.0036;
b = 7.48;
x = linspace(1,1000,250);
for t=1:length(x)-1
L(t+1) = b*A(t)*exp(-cea*A(t)-cel*L(t));
P(t+1) = L(t)*(1-ml);
A(t+1) = P(t)*(1-mp)*exp(-cpa*A(t))+A(t)*(1-ma);
end
L(t)
P(t)
A(t)
figure(1)
plot(x,A)
grid
xlabel('Time (Units)')
ylabel('A (Units)')
  2 个评论
Erin W
Erin W 2016-9-20
Thank you so much! It runs perfectly. I really appreciate it. :) I'm glad I was just slightly off and not completely lost.
Thanks!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by