odextend

Extends the solution of an ODE initial value problem to a later time.

Category: Mathematics > Numerical Integration and Differential Equations

Syntax

solext = odextend(sol, odefun, tfinal)

Continues the integration of sol up to tfinal.

solext = odextend(sol, odefun, tfinal, yinit)

Restarts from the new initial value yinit at the end of sol.

solext = odextend(sol, odefun, tfinal, yinit, options)

Also changes the integration options.

Description

When you find out later that the integration interval was too short, or you want to change the equation or restart with a jump in the state, odextend continues without redoing the work already done. The result is a single structure for the full interval.

Input arguments

sol
Structure returned by an ODE solver called with one output.
odefun
Function to integrate in the extension, or [] to reuse the original.
tfinal
New final time, beyond the end of sol.
yinit
Optional new initial value.

Output arguments

solext
Solution structure covering the original and the extended interval, usable with deval.

Example

Extending from t = 1 to t = 2

f = @(t, y) -y;
sol = ode45(f, [0 1], 1);
solext = odextend(sol, [], 2);
solext.x(end)
y = deval(solext, 1.5);
fprintf('%.4f %.4f\n', y, exp(-1.5))
Output
ans = 2
0.2231 0.2231

See also

ode45 deval odeset bvpxtend