Frequency Transfer Function (FRD)
The frequency transfer function (frequency response) is defined using sets of frequencies and complex numbers expressing the system's response to these frequencies.
This is a convenient way to store system frequency response data for visualization or use in calculations.
Pkg.add("ControlSystemsBase")
In [ ]:
using EngeeControlSystems # To use the frd function
using ControlSystemsBase # For the construction of the LFCH
using CSV # To download experimental data from the table
Loading data from a table
In [ ]:
df = CSV.read("frd_data.csv", DataFrame)
freq = df.freq
resp = [parse(ComplexF64, r) for r in df.resp]; # Converting from String to ComplexF64
Creating a Frequency Response Model
In [ ]:
sys = frd(resp, freq)
Out[0]:
Construction of the LFCH
In [ ]:
magnitude, phase, _ = bode(sys, freq)
Out[0]:
In [ ]:
magnitude = reshape(magnitude, size(magnitude, 3),)
phase = reshape(phase, size(phase, 3),)
Out[0]:
In [ ]:
p1 = plot(freq, 20*log10.(magnitude), ylabel = "L, dB", legend = :none)
p2 = plot(freq, phase, xlabel = "Oh, I'm glad/s", ylabel = ", hail", legend = :none)
plot(p1, p2, layout = (2,1), grid = false, framestyle = :box, xscale=:log10, xlims = (0.1,100))
Out[0]: