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

5 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Star Strider
Star Strider el 15 de Sept. de 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 comentarios
Erin W
Erin W el 20 de Sept. de 2016
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 el 20 de Sept. de 2016
My pleasure!
You were quite close. I only made two minor changes.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by