How to solve for a dependent system of difference (recursive) equations?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Erin W
am 15 Sep. 2016
Kommentiert: Star Strider
am 20 Sep. 2016
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 Kommentare
Akzeptierte Antwort
Star Strider
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!