fig,axs
=
plt.subplots(
3
,
1
)
fig.set_size_inches((
16
,
16
))
plt.subplots_adjust(hspace
=
0.5
)
ax
=
axs[
0
]
ax.stem(n
+
M, h, basefmt
=
'b-'
, use_line_collection
=
'True'
)
ax.set_xlabel(
"Sample number $n$"
, fontsize
=
20
)
ax.set_ylabel(
" $h_n$"
, fontsize
=
24
)
ax.set_title(
'Truncated Impulse response $h_n$ of the Filter'
, fontsize
=
20
)
ax
=
axs[
1
]
ax.plot(w
-
np.pi,
abs
(np.fft.fftshift(Hh)))
ax.axis(xmax
=
np.pi
/
2
, xmin
=
-
np.pi
/
2
)
ax.vlines([
-
wc,wc],
0
,
1.2
, color
=
'g'
, lw
=
2.
, linestyle
=
'--'
,)
ax.hlines(
1
,
-
np.pi, np.pi, color
=
'g'
, lw
=
2.
, linestyle
=
'--'
,)
ax.set_xlabel(r
"Normalized frequency $\omega$"
,fontsize
=
22
)
ax.set_ylabel(r
"$|H(\omega)| $"
,fontsize
=
22
)
ax.set_title(
'Frequency response of $h_n$ '
, fontsize
=
20
)
ax
=
axs[
2
]
ax.plot(w
-
np.pi,
20
*
np.log10(
abs
(np.fft.fftshift(Hh))))
ax.axis(ymin
=
-
80
,xmax
=
np.pi
/
2
,xmin
=
-
np.pi
/
2
)
ax.vlines([
-
wc,wc],
10
,
-
80
, color
=
'g'
, lw
=
2.
, linestyle
=
'--'
,)
ax.hlines(
0
,
-
np.pi, np.pi, color
=
'g'
, lw
=
2.
, linestyle
=
'--'
,)
ax.set_xlabel(r
"Normalized frequency $\omega$"
,fontsize
=
22
)
ax.set_ylabel(r
"$20\log_{10}|H(\omega)| $"
,fontsize
=
18
)
ax.set_title(
'Frequency response of the Filter in dB'
, fontsize
=
20
)