Very simple use of ode45 trying to solve dy/dt = -y+y^2
My code is:
y0=2;
t=linspace(0,3,100);
func=@(t,y) -y+y.^2;
[t,y] = ode45 (func, t, y0);
Keep getting "Warning: Failure at t=6.93...e-01 Unable to meet integration tolerances without reducing step size.
Thanks in Advance!

回答 (1 件)

Star Strider
Star Strider 2017 年 12 月 23 日

1 投票

The derivative increases significantly at t=6.931342e-01, so the solver cannot provide results with acceptable floating-point accuracy without reducing the adaptive time step size below the smallest value allowed (1.776357e-15).
It is a warning, not an error.
To see the reason, add this after your ode45 call:
figure(1)
plot(t, y, t, func(t,y))
legend('y(t)', 'dy(t)/dt', 'Location','N')

カテゴリ

質問済み:

2017 年 12 月 23 日

回答済み:

2017 年 12 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by