Created
June 3, 2012 14:29
-
-
Save gufodotto/2863741 to your computer and use it in GitHub Desktop.
Lorentz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(deSolve) # require this library | |
Lorenz<-function(t, state, parameters) { | |
with(as.list(c(state, parameters)),{ | |
# rate of change | |
dX <- a*X + Y*Z | |
dY <- b * (Y-Z) | |
dZ <- -X*Y + c*Y - Z | |
# return the rate of change | |
list(c(dX, dY, dZ)) | |
} | |
) # end with(as.list ... | |
} | |
# define controlling parameters | |
parameters <- c(a = -8/3, b = -10, c = 28) | |
# define initial state | |
state <- c(X = 1, Y = 1, Z = 1) | |
# define integrations times | |
times <- seq(0, 100, by = 0.001) | |
# perform the integration and assign it to variable 'out' | |
out<-ode(y = state, times = times, func = Lorenz, parms = parameters) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment