Bode plot of DSP filter?

I designed a discrete Butterworth filter using the DSP package. How can I create a Bode plot of the transfer function?

using DSP

function create_filter(cut_off_freq; order=4, type=:Butter, dt)
    if type == :Butter
        return Filters.digitalfilter(Filters.Lowpass(cut_off_freq; fs=1/dt), Filters.Butterworth(order))
    elseif type == :Cheby1
        return Filters.digitalfilter(Filters.Lowpass(cut_off_freq; fs=1/dt), Filters.Chebyshev1(order, 0.01))
    end
end

dt = 0.05
cut_off_freq = 2.0 # Hz
butter = create_filter(cut_off_freq; order=4, dt)
using ControlSystemsBase, Plots
bodeplot(tf(butter))

3 Likes