The following code works on my local machine but not Julia box. [only last part is relevant] But I think it should work on Julia Box by default? By doesn't work, I mean that the plot is static.
using Interact
import PyPlot; const plt = PyPlot
type SecondOrderSystem
τ::Float64
ξ::Float64
end
function y_ovr_KM(t::Float64, system::SecondOrderSystem)
# underdamped
if system.ξ < 1.0
# from lecture notes
a = system.ξ / system.τ
b = sqrt(1.0 - system.ξ) / system.τ
return (1 - exp(-a * t) *(
cos(b * t) + system.ξ / sqrt(1.0 - system.ξ) * sin(b * t)))
# critically damped
elseif system.ξ == 1.0
return 1.0 - (1.0 + t / system.τ) * exp(-t / system.τ)
# overdamped
elseif system.ξ > 1.0
τ₁ = system.τ / (system.ξ - sqrt(system.ξ ^ 2 - 1.0))
τ₂ = system.τ / (system.ξ + sqrt(system.ξ ^ 2 - 1.0))
return 1.0 - (τ₁ * exp(-t / τ₁) - τ₂ * exp(-t / τ₂)) / (τ₁ - τ₂)
end
fig = plt.figure()
t_ovr_tau = collect(linspace(0, 16, 100))
@manipulate for ξ=0.0:0.1:5.0; PyPlot.withfig(fig) do
τ = 1.0 # this plot does not depend on tau* system.τ
system = SecondOrderSystem(τ, ξ)
y = y_ovr_KM.(t_ovr_tau * system.τ, system)
plt.plot(t_ovr_tau, y, c="green", label="output")
plt.xlabel("\$t/ \\tau\$")
plt.ylabel("\$y/(KM)\$")
plt.ylim([0, 1.6])
plt.axhline(y=1, color="k", linestyle="--")
end
end
The following code works on my local machine but not Julia box. [only last part is relevant] But I think it should work on Julia Box by default? By doesn't work, I mean that the plot is static.