solveODE | R Documentation |
Solve a system of ordinary differential equations via a fourth order Runge-Kutta numerical integration scheme.
solveODE(FUN, initial=NULL, step=0.01, n.sample=1000, n.transient=100, ...)
FUN |
a function defining the system of ODEs. This function should have as an input X, where X is a vector whose length is equal to the order of the ODEs. It should return a value for each order (state) of the system. |
... |
additional arguments sent directly to |
initial |
a vector of initial values, one element for each state of the system defined by the ODEs.
By default, this value is |
n.sample |
the number of desired samples for each state beyond that specified for the
transient ala |
n.transient |
the number of transient points. These points are excluded from the output. Default: 100. |
step |
a numerical integration time step. Default: 0.1. |
a data.frame
containing the estimated system response variables.
par
.
## estimate response of the chaotic Lorenz system "lorode" <- function(x, sigma = 10, r = 28, b = 8/3){ c(sigma * (x[2] - x[1]), x[1] * (r - x[3]) - x[2], - b * x[3] + x[1] * x[2]) } z <- solveODE(lorode, initial=c(0.1,0.3,1), n.transient=1500, n.sample=2000) nms <- c("X","Y","Z") ## plot the results stackPlot(x=seq(150, by=0.1, length=2000), y=z, ylab=nms, main="Lorenz System in Chaos", xlab="Time")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.