Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

using Plots, ControlSystemsBase, Plots.Measures
4.7 s
begin
num = [2000, 1000]
den = [1, 60, 500, 0]
sys = tf(num, den)
pp = bodeplot(sys, xminorticks=true, yminorticks=true, layout=(1,2), size=(800,300), margins=5mm, label=false, xlabel="Frequency [rad/s]")
scatter!(pp[1], [1], [2], marker=:o, markersize=3, label=false)
vline!(pp[1], [0.5, 10, 50], label=false, title="Magnitude")
vline!(pp[2], [0.5, 10, 50], label=false, title="Phase")
annotate!(pp[1], 0.1, 90, text("Slope -1", 6))
annotate!(pp[1], 1, 1, text("Point: (1,2)", 6))
annotate!(pp[1], 1.5, 10, text("Slope 0", 6))
annotate!(pp[1], 22, 1, text("Slope -1", 6))
annotate!(pp[1], 190, 0.1, text("Slope -2", 6))

annotate!(pp[2], 0.1, -90, text("Type 1: -90", 6))
annotate!(pp[2], 2, -60, text("Type 2a: +90", 6))
annotate!(pp[2], 22, -100, text("Type 2b: -90", 6))
annotate!(pp[2], 190, -150, text("Type 2b: -90", 6))
3.6 s
savefig(plot(pp[1]), joinpath(@__DIR__, "output/ex2_mag"));
24.2 ms
savefig(plot(pp[2]), joinpath(@__DIR__, "output/ex2_pha"));
25.8 ms
begin
numerator = [1e-2, 1e-4, 1e-2]
denominator = [1/64, 2e-2/8, 1, 0, 0]
gg = bodeplot(sys2, xminorticks=true, yminorticks=true, layout=(1,2), size=(800,300), margins=5mm, label=false, xlabel="Frequency [rad/s]")
vline!(gg[1], [1,8], label=false, title="Magnitude")
vline!(gg[2], [1,8], label=false, title="Phase")
annotate!(gg[1], 0.1, 1, text("Slope -2", 6))
annotate!(gg[1], 3, 0.0001, text("Slope 0", 6))
annotate!(gg[1], 100, 0.0001, text("Slope -2", 6))
scatter!(gg[1], [1], [1e-2], marker=:o, markersize=3, label=false)
annotate!(gg[1], 1, 0.05, text("Point: (1,0.01)", 6))
annotate!(gg[2], 0.1, -170, text("Phase -180", 6))
annotate!(gg[2], 3, -60, text("Phase 0", 6))
annotate!(gg[2], 100, -170, text("Phase -180", 6))
end
498 ms
savefig(plot(gg[1]), joinpath(@__DIR__, "output/ex3_mag"));
28.4 ms
savefig(plot(gg[2]), joinpath(@__DIR__, "output/ex3_pha"));
25.4 ms