deval
Evaluates a differential equation solution structure at given points.
Category: Mathematics > Numerical Integration and Differential Equations
Syntax
y = deval(sol, x)
Returns the solution at the points x.
y = deval(sol, x, idx)
Returns only the solution components listed in idx.
[y, yp] = deval(sol, x)
Also returns the first derivative.
Description
Solvers return the solution only at their own steps. deval interpolates between them using the solver's method, so the result is smoother and more accurate than interpolating the stored points linearly.
Points outside the interval of the solution are extrapolated or rejected depending on the solver, so stay inside.
Input arguments
sol- Structure returned by a solver called with a single output, such as
ode45,bvp4c,dde23orpdepevariants. x- Points inside the solved interval.
idx- Indices of the components wanted.
Output arguments
y- Matrix with one row per component and one column per point of
x. yp- Derivative values with the same layout (when requested).
Example
Evaluate exp(-t) at t = 0.5
sol = ode45(@(t, y) -y, [0 1], 1);
y = deval(sol, [0.25 0.5])
exp(-[0.25 0.5])
Output
y = 1×2
0.7788 0.6065
ans = 1×2
0.7788 0.6065