Solve system of differential equations using Euler forward and ode45
5 ビュー (過去 30 日間)
古いコメントを表示
I have a basic SIR model which is described by three differential equations:

and I want to solve these using Euler forward and ode45. I have never worked with these types of problems before but from research I have found that for Euler forward I should use the equations:

But all the examples I have seen using this are given initial values for the different parameters, which I haven't. So I don't even know where to start. I would appreciate if someone could push me in the right direction of how to solve this. Thank you!
0 件のコメント
採用された回答
Ameer Hamza
2020 年 9 月 29 日
When using Euler forward, you start with
S(1) = s0; % initial value of S
I(1) = i0; % initial value of I
R(1) = r0; % initial value of R
and then run for loop using the equations in your question
N = % total number of time steps
dT = % length of each time step
for i = 2:N
S(i) = S(i-1) + % equation for Sn in question
I(i) = I(i-1) + % equation for In in question
R(i) = R(i-1) + % equation for Rn in question
end
t = 0:dT:(N-1)*dT;
plot(t, S, t, I, t, R)
See these example of how Euler method can be written in MATLAB
4 件のコメント
Ameer Hamza
2020 年 9 月 30 日
Can you explain what is wrong with this plot? This seems to follow the expected trajectories of the SIR model.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Numerical Integration and Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
