-
sdr.plot.frequency_response(b: ArrayLike, a: ArrayLike =
1, sample_rate: float =1.0, N: int =1024, x_axis: Literal[one - sided] | typing.Literal[two - sided] | typing.Literal[log] ='two-sided', decades: int =4, **kwargs) Plots the frequency response \(H(e^{j\omega})\) of the filter.
- Parameters:¶
- b: ArrayLike¶
The feedforward coefficients \(b_i\).
- a: ArrayLike =
1¶ The feedback coefficients \(a_j\). For FIR filters, this is set to 1.
- sample_rate: float =
1.0¶ The sample rate \(f_s\) of the filter in samples/s.
- N: int =
1024¶ The number of samples \(N\) in the frequency response.
- x_axis: Literal[one - sided] | typing.Literal[two - sided] | typing.Literal[log] =
'two-sided'¶ The x-axis scaling. Options are to display a one-sided spectrum, a two-sided spectrum, or one-sided spectrum with a logarithmic frequency axis.
- decades: int =
4¶ The number of decades to plot when
x_axis="log".- **kwargs
Additional keyword arguments to pass to
matplotlib.pyplot.plot().
Examples¶
See the FIR filters example.
In [1]: h_srrc = sdr.root_raised_cosine(0.5, 10, 10) In [2]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.frequency_response(h_srrc); \ ...: plt.show() ...:
See the IIR filters example.
In [3]: zero = 0.6; \ ...: pole = 0.8 * np.exp(1j * np.pi / 8); \ ...: iir = sdr.IIR.ZerosPoles([zero], [pole, pole.conj()]) ...: In [4]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.frequency_response(iir.b_taps, iir.a_taps); \ ...: plt.show() ...:
In [5]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.frequency_response(h_srrc, x_axis="one-sided"); \ ...: plt.show() ...:
In [6]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.frequency_response(iir.b_taps, iir.a_taps, x_axis="log", decades=3); \ ...: plt.show() ...: