频率传递函数(frd)的LFC构造
频率传递函数(频率响应)是使用一组频率和复数来定义系统对这些频率的响应。
这是存储系统频率响应数据以供可视化或在计算中使用的便捷方式。
Pkg.add("ControlSystemsBase")
In [ ]:
using EngeeControlSystems # 使用frd功能
using ControlSystemsBase # 对于LFCH的建设
using CSV # 从表中下载实验数据
从表加载数据
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 = plot(freq, 20*log10.(magnitude), ylabel = "L,dB", legend = :none)
p2 = plot(freq, phase, xlabel = "哦,我很高兴", ylabel = ",冰雹", legend = :none)
plot(p1, p2, layout = (2,1), grid = false, framestyle = :box, xscale=:log10, xlims = (0.1,100))
Out[0]: