频率传递函数(FRD)
频率传递函数(频率响应)是使用一组频率和复数来定义系统对这些频率的响应。
这是存储系统频率响应数据以供可视化或在计算中使用的便捷方式。
In [ ]:
neededLibs = [
"EngeeControlSystems", # 使用frd功能
"ControlSystemsBase", # 对于LFCH的建设
"CSV" # 从表中下载实验数据
]
for lib in neededLibs
try
eval(Meta.parse("using $lib"))
catch ex
Pkg.add(lib)
eval(Meta.parse("using $lib"))
end
end
从表加载数据
In [ ]:
df = CSV.read("frd_data.csv", DataFrame)
freq = df.freq
resp = [parse(ComplexF64, r) for r in df.resp]; # 从字符串转换为ComplexF64
创建频率响应模型
In [ ]:
sys = frd(resp, freq)
Out[0]:
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 = ",冰雹", legend = :none)
Plots.plot(p1, p2, layout = (2,1), grid = false, framestyle = :box, xscale=:log10, xlims = (0.1,100))
Out[0]:
.png)