odeprint
ODE output function: prints the time and state at each step.
Category: Other public functions: funfun
Syntax
status = odeprint(t, y, flag)
Output-function form: called by the solver at the start, at each accepted step and at the end.
Description
Set it with odeset('OutputFcn', @odeprint) to see the numbers the solver produces while it runs, which is handy to debug a model or to see the step size choice. With a tspan of more than two elements the solver reports exactly at those times.
Input arguments
t, y- Time points and state columns passed in by the solver.
flag'init',''or'done'.
Output arguments
status- Logical,
trueto stop the solver. Alwaysfalsehere.
Example
Print at chosen times
opts = odeset('OutputFcn', @odeprint);
[t, y] = ode45(@(t, y) -y, [0 0.1 0.2], 1, opts);
Output
t = 0
y = 1
t = 0.1000
y = 0.9048
t = 0.2000
y = 0.8187