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

jcbritobr
Fri, 25 Jul 2025 21:04:47 +0000
General Usage

Hello. Good evening.

I’m doing all exercises of the Sadiku’s book in julia programming.

estantevirtual.com.br

Fundamentals Of Electrics Circuits - Crisalida Livraria | Estante Virtual

Fundamentals Of Electrics Circuits de Charles Alexander Matthew No Sadiku, Mcgraw Hill por 270.00 no Crisalida Livraria. Estante Virtual, a maior rede de sebos online do Brasil.

The code is in github

github.com

GitHub - jgardona/cfundamentals: Exercises, practical problems and examples from...

Exercises, practical problems and examples from Fundamentals of Electric Circuits, 7th edition using Julia programming language.

Im stucked to plot the impulse unit function after get it differentiating the unit step function.
The plot I get is only a line in zero, as plots.jl cant understand that the interval is all zero for values != t0. May someone help?

code:

let
	@syms t t₀

	u = sympy.Piecewise(
		(0, Lt(t, 0)),
		(1, Gt(t, 0))
	)
	@info u
	uₜ₀ = subs(u, t=> t - t₀)
	vₜ = 10(subs(uₜ₀, t₀=>2) - subs(uₜ₀, t₀=>5))
	@info vₜ
	p1 = plot(vₜ, xlims=(0, 6), lw=3, legend=:none, size=(400, 300))
	xlabel!(L"t")
	ylabel!(L"v(t)")
	title!(L"Pulso de Tensão $v(t)$")

	δ = diff(vₜ)
	# Ainda não sei como plotar a função de impulso unitário.
	@info δ
    plot( δ)
end

Results issues

Correct

7 posts - 3 participants