How to solve ODE system numerically
22 ビュー (過去 30 日間)
古いコメントを表示
Hello. I am trying to get a solution from this system:
a1 = 0.7;
a2 = 0.4;
b1 = 0.06;
b2 = 0.08;
c1 = 8787168;
c2 = 8111232;
syms x(t) y(t);
ode1 = diff(x) == (-a1)*x + b1*(c1-x)*y;
ode2 = diff(y) == (-a2)*y + b2*(c2-y)*x;
odes = [ode1,ode2]
cond1 = x(0) == 15000;
cond2 = y(0) == 17000;
conds = [cond1,cond2]
dsolve(odes,conds);
But Matlab cannot come to an explicit solution. How can I produce a numerical one?
Thank you.
0 件のコメント
採用された回答
Jan
2021 年 5 月 6 日
編集済み: Jan
2021 年 5 月 6 日
a1 = 0.7;
a2 = 0.4;
b1 = 0.06;
b2 = 0.08;
c1 = 8787168;
c2 = 8111232;
y0 = [15000, 17000];
tSpan = [0, 0.0001]; % The values explode for higher t
[Y, T] = ode45(@(t,y) fcn(t, y, a1, a2, b1, b2, c1, c2), tSpan, y0);
plot(T, Y)
function dy = fcn(t, y, a1, a2, b1, b2, c1, c2)
dy = [-a1 * y(1) + b1 * (c1 - y(1)) * y(2); ...
-a2 * y(2) + b2 * (c2 - y(2)) * y(1)];
end
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
