solve
Method of the ode object: integrates the differential equation it defines.
Category: Mathematics > Numerical Integration and Differential Equations
Syntax
S = solve(F, t0, tf)
Solves the problem of the ode object F from t0 to tf.
S = solve(F, tspan)
Solves over tspan, a vector of times at which to report the result.
Description
With the object interface, the problem and its settings live together in one variable: set the properties, then call solve. If no solver is named, one is chosen automatically from the problem, so stiffness need not be known in advance.
Events, mass matrices and Jacobians are attached as objects (odeEvent, odeMassMatrix, odeJacobian) rather than through odeset.
Input arguments
F- An
odeobject withODEFcnandInitialValueset (and optionallySolver,InitialTime,RelativeTolerance,EventDefinition). t0, tf- Start and end of the interval.
Output arguments
S- A results object whose
TimeandSolutionproperties hold the time points and the solution, one column per time point.
Example
Solve y' = -y
F = ode;
F.ODEFcn = @(t, y) -y;
F.InitialTime = 0;
F.InitialValue = 1;
S = solve(F, 0, 1);
fprintf('%.4f %.4f\n', S.Solution(end), exp(-1))
Output
0.3679 0.3679
Notes
solve is also the name of a method on other object types. This entry covers the ode object.