y = deval(___,idx) returns
only the solution components with indices listed in the vector idx.
You can use either of the previously listed input argument combinations.

Solve the simple ODE y' = t^2 with initial condition y0 = 0 in the interval $$[0,3]$$ using ode23.

sol = ode23(@(t,y) t^2, [0 3], 0);

Evaluate the solution at seven points. The solution structure sol contains an interpolating function that deval uses to produce a continuous solution at these points. Specify a second output argument with deval to also return the derivative of the interpolating function at the specified points.

x = linspace(0,3,7);
[y,yp] = deval(sol,x)

y = 1×7
0 0.0417 0.3333 1.1250 2.6667 5.2083 9.0000

Solution structure, specified as a structure returned by one
of these differential equation solvers.

Initial value problem solver — ode45, ode23, ode113, ode15s, ode23s, ode23t, ode23tb, ode15i

Delay differential equations solver — dde23, ddesd,
or ddensd

Boundary value problem solver — bvp4c or bvp5c

Example: sol = ode45(@myode,tspan,y0)

Data Types: struct

x — Evaluation points vector

Evaluation points, specified as a vector. x specifies
the points at which you want the value of the solution. The elements
of x must be contained in the original integration
interval, [sol.x(1) sol.x(end)]. For each index i,
the solution y(:,i) corresponds to x(i).

Example: 0:0.1:1

Example: [2
3 5 8]

Data Types: single | double

idx — Solution components to return vector

Solution components to return, specified as a vector. Use this
input when you are only interested in certain components of the solution.

Example: y = deval(sol,x,[2 3]) returns only
the second and third solution components.

Interpolated solution, returned as a vector or matrix. The number
of rows in y is equal to the number of solution
components being returned.

For multipoint boundary value problems, the solution obtained
by bvp4c or bvp5c might
be discontinuous at the interfaces. For an interface point xc,
the deval function returns the average of the
limits from the left and right of xc. To get the
limit values, set the value of x to be slightly
larger or smaller than xc.

yp — Derivative of continuous solution produced by sol vector | matrix

Derivative of continuous solution produced by sol,
returned as a vector or matrix. yp is the same
size as y and indicates the slope of the interpolating
function used by sol at each solution point in y.

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.