hey,
i am learning the example
it works but i do not know if it is correct.
using DifferentialEquations, Plots
l = 1.0 # length [m]
m = 1.0 # mass[m]
g = 9.81 # gravitational acceleration [m/s²]
function pendulum!(du,u,p,t)
du[1] = u[2] # θ'(t) = ω(t)
du[2] = -3g/(2l)*sin(u[1]) + 3/(m*l^2)*p(t) # ω'(t) = -3g/(2l) sin θ(t) + 3/(ml^2)M(t)
end
θ₀ = 0.01 # initial angular deflection [rad]
ω₀ = 0.0 # initial angular velocity [rad/s]
u₀ = [θ₀, ω₀] # initial state vector
tspan = (0.0,0.5) # time interval
dt = 0.001
t = 0:dt:0.5
for i = 1:length(t)-1
M = t->V[i] # V = values(P); P external torque [Nm] is a time array
end
prob = ODEProblem(pendulum!,u₀,tspan,M)
sol = solve(prob,DP5(),adaptive=false,dt=0.001) # solver customization for matching the time array domain