matlab.ode.options.ODE78 Properties
matlab.ode.options.ODE78 objects are used with ode objects to
specify options for the solution of ordinary differential equations. ode
objects automatically populate the SolverOptions property with an options object specific to the selected
solver, so you generally do not need to create matlab.ode.options.ODE78 objects
explicitly.
Specify options for the ODE problem by changing property values of the
matlab.ode.options.ODE78 object using dot notation. For example, if
F is an ode object, then
F.SolverOptions.OutputFcn = @odeplot specifies an output function
that the solver calls after each successful time step.
Step Size
Suggested initial step size, specified as a positive scalar. InitialStep
sets an upper bound on the size of the first step that the solver tries.
If you do not specify an initial step size, then the solver bases the initial step size on the
slope of the solution at the initial time point of the integration. If the slope of all
solution components is zero, then the solver might try a step size that is too large. If
you know that the initial step size is too large, or if you want to be sure that the
solver resolves important behavior at the beginning of the integration, then use
InitialStep to provide a suitable initial step size.
Example: F.SolverOptions.InitialStep = 1e-3, where F is an ode object, sets an upper bound of 1e-3 on the size of the initial step.
Maximum step size, specified as a positive scalar. MaxStep sets an upper
bound on the size of any step that the solver takes. If the equation has periodic
behavior, for example, then you can set MaxStep to a fraction of
the period so that the solver does not step over an area of interest.
Do not use
MaxStepjust to obtain more output points, as it can significantly slow down the integration. Instead, use theRefineoption of thesolvemethod to compute additional points at low computational cost.Do not use
MaxStepto increase the accuracy of the solution. If the solution is not accurate enough, then reduce the value ofRelativeToleranceand use the solution to determine a suitable value forAbsoluteTolerance.Avoid using
MaxStepto make sure the solver does not step over some behavior that occurs only once in the integration interval. If you know the time at which the behavior occurs, then break the interval into two pieces and solve each separately. If you do not know the time at which the behavior occurs, try reducingRelativeToleranceandAbsoluteTolerance. UseMaxSteponly as a last resort in this case.
Example: F.SolverOptions.MaxStep = 1e-2, where F is an
ode object, sets an upper bound of 1e-2 on the
step size.
Since R2024b
Minimum step size, specified as a positive scalar. MinStep sets a
lower bound on the size of any step that the solver takes. MinStep
must be less than MaxStep.
Solver steps are limited by floating-point precision regardless of the value of
MinStep.
Example: F.SolverOptions.MinStep = 1e-10, where F
is an ode object, sets a lower bound of 1e-10 on the
step size.
Error Control
Control error relative to the norm of the solution, specified as "off" or
"on". If NormControl is
"on", then the solver controls the error e at
each step using the norm of the solution y rather than its absolute
value:
norm(e(i)) <= max(RelativeTolerance*norm(y(i)),AbsoluteTolerance(i))
Example: F.SolverOptions.NormControl = "on", where F is an ode object, controls step error using the norm of the solution.
Solver Output
Output function, specified as a function handle. solve
calls the output function after each successful time step. If you use solutionFcn to solve the ODE problem, then
OutputFcn is ignored.
This table describes the built-in output functions that you can specify for
OutputFcn.
| Function Name | Description |
|---|---|
odeplot | Plot all components of the solution against time. |
odephas2 | Create a 2-D phase plane plot of the first two solution components. |
odephas3 | Create a 3-D phase plane plot of the first three solution components. |
odeprint | Print the solution and time step to the Command Window. |
If you write a custom output function, then it must use this function signature:
status = myOutputFcn(t,y,flag)
The output function you write must also respond appropriately to these flags.
| Flag | Description |
|---|---|
"init" | The solver calls |
[] | The solver calls
|
"done" | The solver calls |
Example: F.SolverOptions.OutputFcn = @odeplot, where
F is an ode object, specifies
odeplot as the output function that the solver calls after each
successful time step.
Data Types: function_handle
Component selection for the output function, specified as a vector of indices. The
vector specifies which components of the solution to pass to the output function. The
number of solution components is equal to the number of elements in the vector output of
the ODE function (which is stored in the ODEFcn property of the
ode object).
Example: F.SolverOptions.OutputSelection = [1 3], where
F is an ode object, passes the first and third
components of the solution to the output function.
Version History
Introduced in R2023bYou can specify the minimum step size as a solver option by using the
MinStep name-value argument.
See Also
ode | odeJacobian | odeMassMatrix | odeset
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)