How to plot a impulse unit function using Plots.jl and SymPy.jl?

You can try sympy.Heaviside(t) for your u. This will integrate as expected once differentiated.

For plotting you still would have to work to get the right plot as evaluating the derivative at 2 or 5 does not return a numeric value, rather this:

julia> let
       u = sympy.Heaviside(t)
       uₜ₀ = subs(u, t=> t - t₀)
       vₜ = 10(subs(uₜ₀, t₀=>2) - subs(uₜ₀, t₀=>5))
       δ = diff(vₜ)
       δ(2)
       end
10⋅δ(0)

Trying this function might be of interest, but you need to make sure 2 and 5 are points that are chosen to be plotted

f(x) = iszero(δ(x)) ? 0.0 : convert(Float64, (δ(x).o.args[1]))
2 Likes