Reputation: 11
dt/dx=x(1.15-0.02x-0.02y) dt/dy=y(1.34-0.02y-0.04x)
T=15;
dt=1;
N=floor(T/dt);
t(1)=1;
x(1)=21;
y(1)=20;
for i=1:N
x(i+1)=x(i)+dt*x(i)*(1.15-0.02*x(i)-0.02*y(i));
y(i+1)=y(i)+dt*y(i)*(1.34-0.02*y(i)-0.04*x(i));
t(i+1)=i*dt;
end
title('state variable')
subplot(2,1,1)
plot(t,x,'r*-')
subplot(2,1,2)
plot(t,y,'bo-')
Using forward euler method It is correct?
Upvotes: 0
Views: 100
Reputation: 1303
I think so but you have a mistake in Your equation it shoul be
dx/dt=...
dy/dt=...
Upvotes: 1