How to solve for a dependent system of difference (recursive) equations?
5 views (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
Star Strider
on 15 Sep 2016
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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!