Created
January 26, 2020 15:24
-
-
Save ueliwechsler/d023a5fcc2a070d1b5af151ad48d3349 to your computer and use it in GitHub Desktop.
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
# Example for Plots.jl http://docs.juliaplots.org/latest/#simple-is-beautiful | |
using Plots | |
# define the Lorenz attractor | |
mutable struct Lorenz | |
dt; σ; ρ; β; x; y; z | |
end | |
function step!(l::Lorenz) | |
dx = l.σ*(l.y - l.x) ; l.x += l.dt * dx | |
dy = l.x*(l.ρ - l.z) - l.y ; l.y += l.dt * dy | |
dz = l.x*l.y - l.β*l.z ; l.z += l.dt * dz | |
end | |
attractor = Lorenz((dt = 0.02, σ = 10., ρ = 28., β = 8//3, x = 1., y = 1., z = 1.)...) | |
# initialize a 3D plot with 1 empty series | |
plt = plot3d(1, xlim=(-25,25), ylim=(-25,25), zlim=(0,50), | |
title = "Lorenz Attractor", marker = 2) | |
@gif for i=1:1500 | |
step!(attractor) | |
push!(plt, attractor.x, attractor.y, attractor.z) | |
end every 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment