一阶低通滤波器
H ( j ω ) = u o u i = 1 j ω C R + 1 j ω C = 1 1 + j ω R C H(j\omega )=\frac{u_o}{u_i}=\cfrac{\frac{1}{j\omega C}}{R+\frac{1}{j\omega C}}=\cfrac{1}{1+j\omega RC} H(jω)=uiuo=R+jωC1jωC1=1+jωRC1
截止频率
通常截止频率时输出功率为传导频率的一半,即输出电压为输入电压的
1
/
2
\sqrt{1/2}
1/2
当
ω
0
=
2
π
f
0
=
1
R
C
\omega_0=2\pi f_0=\frac{1}{RC}
ω0=2πf0=RC1时,
H
(
j
ω
0
)
=
1
1
+
i
=
1
2
(
1
−
i
)
H(j\omega_0)=\frac{1}{1+i}=\frac{1}{2}(1-i)
H(jω0)=1+i1=21(1−i)
幅值:
∣
H
(
j
ω
0
)
∣
=
0.5
=
−
3
d
B
|H(j\omega_0)|=\sqrt{0.5}=-3dB
∣H(jω0)∣=0.5=−3dB
相角:
∠
∣
H
(
j
ω
0
)
∣
=
−
π
4
∠|H(j\omega_0)|=-\frac{\pi}{4}
∠∣H(jω0)∣=−4π
Matplotlib绘制频率响应图
matlibplot绘图知识点
- matplotlib显示希腊字母
‘$\omega$’ - matplotlib绘制对数图(半对数线图)
semilogx(),semilogy() - matplotllib两个不同的Y轴在一张图上一左一右显示
twinx() 函数 - matplotlib设置颜色,标签,线型
- matplotlib使用subplots()
- matplotlib设置刻度线的颜色,宽度等
tick_params()
import numpy as np
import matplotlib.pyplot as plt
import control as ctr
R=1e8
C=1e-12
w0=1/R/C
w=np.logspace(0,5,1000)
Hs=1/(1+w*1j*R*C)
fig, ax1 = plt.subplots()
color = 'tab:red'
ax1.set_xlabel('$\omega$')
ax1.set_ylabel('|H(s)| (dB)', color=color)
ax1.semilogx(w, ctr.mag2db(abs(Hs)), color=color)
ax1.tick_params(axis='y', labelcolor=color)
ax1.semilogx(w0, -3, color=color,marker='o')
idx1=np.where(w0<w)
ax1.semilogx([w[0],w[idx1[0][0]]],[-3,-3],'--g')
plt.xlim(1,1e5)
ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
color = 'tab:blue'
ax2.set_ylabel('Angle', color=color) # we already handled the x-label with ax1
ax2.semilogx(w, np.angle(Hs), color=color)
ax2.tick_params(axis='y', labelcolor=color)
ax2.semilogx(w0, -np.pi/4, color=color,marker='o')
ax2.semilogx([w0,w0],[0,-np.pi/2],'--g')
ax2.semilogx([w[idx1[0][0]],w[-1]],[-np.pi/4,-np.pi/4],'--g')
fig.tight_layout() # otherwise the right y-label is slightly clipped
plt.grid()
plt.show()
代码运行结果如下
如图所示,设R=1e8,C=1e-12,在截止频率10e4时,频率响应的幅值为-3dB,相角为
−
π
4
-\frac{\pi}{4}
−4π