フィルターのクリア

Can't figure out why my ODE solver is producing a straight line

1 回表示 (過去 30 日間)
Christopher Arreola
Christopher Arreola 2022 年 5 月 11 日
回答済み: Star Strider 2022 年 5 月 11 日
Here's my code, can't figure out why it's only giving my a straight line, this is supposed to be a system of 3 nonlinear ODE's and produce a periodic graph for all three ODE's
function ODE
f=@(t,x)[x(1).*(0.9842-0.9844.*x(1)-x(3)-0.0004.*x(2));(1+x(2)).*(0.0156.*x(1)-0.0004.*x(2));0.0002.*x(2)-0.0002.*x(3)+x(3).*(0.0156.*x(1)-0.0004.*x(2))];
[t,xa]=ode45(f,[0 50],[0 0 0]);
plot(t,xa(:,1),'r')
hold on
plot(t,xa(:,2),'b')
plot(t,xa(:,3),'g')
hold off

採用された回答

Star Strider
Star Strider 2022 年 5 月 11 日
It plots a straight line because all the initial conditions arre zero.
Add eps (or some small, non-zero value) to them, and it works —
f=@(t,x)[x(1).*(0.9842-0.9844.*x(1)-x(3)-0.0004.*x(2));(1+x(2)).*(0.0156.*x(1)-0.0004.*x(2));0.0002.*x(2)-0.0002.*x(3)+x(3).*(0.0156.*x(1)-0.0004.*x(2))];
[t,xa]=ode45(f,[0 50],[0 0 0]+eps);
plot(t,xa(:,1),'r')
hold on
plot(t,xa(:,2),'b')
plot(t,xa(:,3),'g')
hold off
legend('x_1','x_2','x_3', 'Location','best')
set(gca, 'YScale','log') % Optional
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by