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.
In [ ]:
neededLibs = [
"EngeeControlSystems", # To use the frd function
"ControlSystemsBase", # For the construction of the LFCH
"CSV" # To download experimental data from the table
]
for lib in neededLibs
try
eval(Meta.parse("using $lib"))
catch ex
Pkg.add(lib)
eval(Meta.parse("using $lib"))
end
end
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 = Plots.plot(freq, 20*log10.(magnitude), ylabel = "L, dB", legend = :none)
p2 = Plots.plot(freq, phase, xlabel = "ω, рад/с", ylabel = ", hail", legend = :none)
Plots.plot(p1, p2, layout = (2,1), grid = false, framestyle = :box, xscale=:log10, xlims = (0.1,100))
Out[0]:
