Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# odextend

Extend solution of initial value problem for ordinary differential equation

## Syntax

solext = odextend(sol, odefun, tfinal)
solext = odextend(sol,[],tfinal)
solext = odextend(sol, odefun, tfinal, yinit)
solext = odextend(sol, odefun, tfinal, [yinit, ypinit])
solext = odextend(sol, odefun, tfinal, yinit, options)

## Description

solext = odextend(sol, odefun, tfinal) extends the solution stored in sol to an interval with upper bound tfinal for the independent variable. Specify odefun as a function handle. Specify sol as an ODE solution structure created using an ODE solver. The lower bound for the independent variable in solext is the same as in sol. If you created sol with an ODE solver other than ode15i, the function odefun computes the right-hand side of the ODE equation, which is of the form y′ = f(t,y). If you created sol using ode15i, the function odefun computes the left-hand side of the ODE equation, which is of the form f(t,y,y′) = 0.

Parameterizing Functions explains how to provide additional parameters to the function odefun, if necessary.

odextend extends the solution by integrating odefun from the upper bound for the independent variable in sol to tfinal, using the same ODE solver that created sol. By default, odextend uses

• The initial conditions y = sol.y(:,end) for the subsequent integration

• The same integration properties and additional input arguments the ODE solver originally used to compute sol. This information is stored as part of the solution structure sol and is subsequently passed to solext. Unless you want to change these values, you do not need to pass them to odextend.

solext = odextend(sol,[],tfinal) uses the same ODE function that the ODE solver uses to compute sol to extend the solution. It is not necessary to pass in odefun explicitly unless it differs from the original ODE function.

solext = odextend(sol, odefun, tfinal, yinit) uses the column vector yinit as new initial conditions for the subsequent integration, instead of the vector sol.y(end).

 Note   To extend solutions obtained with ode15i, use the following syntax, in which the column vector ypinit is the initial derivative of the solution: solext = odextend(sol, odefun, tfinal, [yinit, ypinit])

solext = odextend(sol, odefun, tfinal, yinit, options) uses the integration properties specified in options instead of the options the ODE solver originally used to compute sol. The new options are then stored within the structure solext. See odeset for details on setting options properties. Set yinit = [] as a placeholder to specify the default initial conditions.

## Examples

The following command

sol=ode45(@vdp1,[0 10],[2 0]);

uses ode45 to solve the system y' = vdp1(t,y), where vdp1 is an example of an ODE function provided with MATLAB® software, on the interval [0 10]. Then, the commands

sol=odextend(sol,@vdp1,20);
plot(sol.x,sol.y(1,:));

extend the solution to the interval [0 20] and plot the first component of the solution on [0 20].