필터 지우기
필터 지우기

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!
Star Strider
Star Strider 2016년 9월 20일
My pleasure!
You were quite close. I only made two minor changes.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by