solutionFcn
Method of the ode object: returns a function handle that evaluates the solution at any time.
Category: Mathematics > Numerical Integration and Differential Equations
Syntax
sfun = solutionFcn(F, t0, tf)
Solves the problem defined by the ode object F on [t0 tf] and returns a handle sfun(t).
Description
This is the object-based counterpart of calling a solver with a single output and then deval. The integration runs once, when solutionFcn is called, and the handle interpolates between the computed steps.
The solver is chosen by the Solver property of the object, which defaults to automatic selection.
Input arguments
F- An
odeobject withODEFcn,InitialTimeandInitialValueset. t0, tf- Start and end of the interval to solve.
Output arguments
sfun- Function handle:
y = sfun(t)returns the solution at the timestinside[t0 tf].
Example
Handle to y' = -y
F = ode;
F.ODEFcn = @(t, y) -y;
F.InitialTime = 0;
F.InitialValue = 1;
sfun = solutionFcn(F, 0, 1);
fprintf('%.4f %.4f\n', sfun(0.5), exp(-0.5))
Output
0.6065 0.6065