numericalSolution {phaseR} | R Documentation |
Numerical solution and plotting
Description
Numerically solves a two-dimensional autonomous ODE system for a given
initial condition, using ode
from the package
deSolve
. It then plots the dependent variables against
the independent variable.
Usage
numericalSolution(
deriv,
y0 = NULL,
tlim,
tstep = 0.01,
parameters = NULL,
type = "one",
col = c("red", "blue"),
add.grid = TRUE,
add.legend = TRUE,
state.names = c("x", "y"),
xlab = "t",
ylab = state.names,
method = "ode45",
...
)
Arguments
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function |
y0 |
The initial condition. Should be a |
tlim |
Sets the limits of the independent variable for which the
solution should be plotted. Should be a |
tstep |
The step length of the independent variable, used in numerical
integration. Decreasing the absolute magnitude of |
parameters |
Parameters of the ODE system, to be passed to |
type |
If set to |
col |
Sets the colours of the trajectories of the two dependent
variables. Should be a |
add.grid |
Logical. If |
add.legend |
Logical. If |
state.names |
The state names for |
xlab |
Label for the x-axis of the resulting plot. |
ylab |
Label for the y-axis of the resulting plot. |
method |
Passed to |
... |
Additional arguments to be passed to
|
Value
Returns a list
with the following components:
add.grid |
As per input. |
add.legend |
As per input. |
col |
As per input, but with possible editing if a
|
deriv |
As per input. |
method |
As per input. |
parameters |
As per input. |
t |
A |
tlim |
As per input. |
tstep |
As per input. |
x |
A |
y |
A |
y0 |
As per input. |
Author(s)
Michael J Grayling
See Also
Examples
# A two-dimensional autonomous ODE system, vanDerPol.
vanDerPol_numericalSolution <- numericalSolution(vanDerPol,
y0 = c(4, 2),
tlim = c(0, 100),
parameters = 3)