MATLAB: Solving a nonlinear ODE using ode45

nonlinearode45

f = @(t,y) [y(2); y(3); -y(3)-y(2)-y(1)+y(1)^2];
[t,y] = ode45(f,[0 30],[1;5;10]);
MatLab is telling me that it can't meet the integration tolerances, what can I do to fix this?

Best Answer

There is nothing wrong with your ODE except that it takes off to infinity at about t=3. You have to decide if this is appropriate behaviour of if you need to change it.
To see its behaviour, plot it:
f = @(t,y) [y(2); y(3); -y(3)-y(2)-y(1)+y(1)^2];
[t,y] = ode45(f,[0 30],[1;5;10]);
figure(1)
semilogy(t, y)
grid
Related Question