The sol of the “DifferentialEquations.jl” package can be nicely drawn with Plots, like the following
But if you use the “PyPlot.jl” package, how do you draw the sol curve?
The IDE I use is Pluto
using DifferentialEquations
import PyPlot as plt
let
l = 1.0
m = 1.0
g = 9.81
function pendulum!(du,u,p,t)
du[1] = u[2]
du[2] = -3g/(2l)*sin(u[1]) + 3/(m*l^2)*p(t)
end
θ₀ = 0.01
ω₀ = 0.0
u₀ = [θ₀, ω₀]
tspan = (0.0,10.0)
M = t->0.1sin(t)
prob = ODEProblem(pendulum!,u₀,tspan,M)
sol = solve(prob)
plt.clf()
plt.plot(sol.t, sol[1,:])
plt.gcf()
end