Borrar filtros
Borrar filtros

Need the backward trajectories of ode plot

1 visualización (últimos 30 días)
Atom
Atom el 14 de Jul. de 2013
I have a system of differential equations which I can solve by Euler's method. The following code gives a plot of a trajectory that starts from x(1)=0.7; y(1)=0.11; and depicts its evolution in forwarding time. But I need a trajectory that starts from x(1)=0.7; y(1)=0.11; and evolved in backward time. That mean what will be the plot if t tends to -infinity. Please correct my code so that I can get backword evolution of trajectories:
clear
alpha=.5;gamma=1; delta=0.3; L=.4; beta=1.778;
x(1)=0.7;
y(1)=0.11;
t(1)=0;
for i=1:50000
t(i+1)=t(i)+.01;
x(i+1)=x(i)+.01*[x(i)*((1-x(i))*(x(i)/L-1)-beta*y(i)/(x(i)+alpha))];
y(i+1)=y(i)+.01*[beta*x(i)*y(i)/(x(i)+alpha)-gamma*y(i)-delta*y(i)^2];
end
plot(x,y, 'b')
axis([.4 1 0 .22])

Respuestas (1)

Jan
Jan el 14 de Jul. de 2013
Do you ask for changing the line:
t(i+1) = t(i) + 0.01;
to
t(i+1) = t(i) - 0.01;
?
  4 comentarios
Atom
Atom el 16 de Jul. de 2013
Editada: Atom el 16 de Jul. de 2013
Do you mean this?
alpha=.5;gamma=1; delta=0.3; L=.4; beta=1.778;
x(50000)=0.7;
y(50000)=0.11;
t(50000)=0;
for i=50000:1
t(i+1)=t(i)-.01;
x(i+1)=x(i)+.01*[x(i)*((1-x(i))*(x(i)/L-1)-beta*y(i)/(x(i)+alpha))];
y(i+1)=y(i)+.01*[beta*x(i)*y(i)/(x(i)+alpha)-gamma*y(i)-delta*y(i)^2];
end
plot(x,y, 'b')
axis([.4 1 0 .22])
But this does not servers the purpose. Please help me to solve the issue. I am very sorry for the inconvenience for the repeated request.
Jan
Jan el 16 de Jul. de 2013
Editada: Jan el 16 de Jul. de 2013
"for i=50000:1" does not enter the loop at all. You need the stepsize of -1.
I cannot test it currently, but let me guess:
for i = 50000:-1:2
t(i-1) = t(i) - 0.01;
x(i-1) = x(i) + 0.01*[x(i)*((1-x(i))*(x(i)/L-1)-beta*y(i)/(x(i)+alp ha))];
y(i-1) = y(i) + 0.01*[beta*x(i)*y(i)/(x(i)+alpha)-gamma*y(i)-delta*y(i)^2];
end

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by