Last active
January 26, 2020 12:56
-
-
Save ueliwechsler/aa5017e98c21a6e540db57177f8c378e 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
using DifferentialEquations | |
α = 1 | |
β = 0.1 | |
γ = 0.05 | |
δ = 0.02 | |
function lotka_voltera!(dx, x, p, t) | |
dx[1] = α*x[1] - β*x[1]*x[2] | |
dx[2] = δ*x[1]*x[2] - γ*x[2] | |
end | |
x0 = [10., # baboon | |
10] # cheetah | |
tspan = (0.0,100.0) | |
prob = ODEProblem(lotka_voltera!, x0, tspan) | |
sol = solve(prob) | |
using Plots | |
plot(sol.t, sol[1,:]; label="baboon") | |
plot!(sol.t, sol[2,:]; label="cheetah") | |
p = plot(sol); | |
p.series_list[1][:label] = "baboons"; | |
p.series_list[2][:label] = "cheetahs"; p | |
xlabel!("time") | |
ylabel!("population size") | |
dir = @__DIR__ | |
savefig(p, joinpath(dir,"test.emf")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment