Coupled ODE Solver Producing Unexpected Graph

조회 수: 1 (최근 30일)
Brooke Mitchell
Brooke Mitchell 2020년 2월 2일
편집: darova 2021년 1월 30일
Incorrect graph generating with given code. Trying to solve a couped ODE problem. Thank you in advance.
clear;
clc;
t_initial=0;
t_final=800;
x0=500;
y0=200;
tSpan=[t_initial t_final];
v0=[x0 y0];
[t,v]=ode45(@ODEfun,tSpan,v0);
figure
plot(t,v(:,1),t,v(:,2));
legend('Fox','Rabbit');
xlabel('Time (days)');
ylabel('Population');
title('Rabbit and Fox Population Overtime');
function f=ODEfun(~,v)
x=v(1);
y=v(2);
k1=0.02;
k2=0.0004;
k3=0.00004;
k4=0.04;
dx_dt=(k1*x)-(k2*y);
dy_dt=(k3*x*y)-(k4*y);
f=[dx_dt;dy_dt];
end
  댓글 수: 2
darova
darova 2020년 2월 2일
Here is what i got for t_final = 80
img1.png
VBBV
VBBV 2020년 11월 29일
I think you seem to get correct graph only for the given input conditions
Do you mean a graph like this below ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Pravin Jagtap
Pravin Jagtap 2020년 2월 6일
Hello Brooke,
Please refer to following documentation for solving coupled system of ODEs

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by