-
sdr.plot.impulse_response(filter: FIR | IIR | ArrayLike | tuple[ArrayLike, ArrayLike], N: int | None =
None
, offset: float =0
, **kwargs) Plots the impulse response \(h[n]\) of a filter.
The impulse response \(h[n]\) is the filter output when the input is an impulse \(\delta[n]\).
- Parameters:¶
- filter: FIR | IIR | ArrayLike | tuple[ArrayLike, ArrayLike]¶
The filter definition.
- N: int | None =
None
¶ The number of samples \(N\) to plot. If
None
, the length ofb
is used for FIR filters and 100 for IIR filters.- offset: float =
0
¶ The x-axis offset to apply to the first sample. Can be useful for comparing the impulse response of filters with different lengths.
- **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(); \ ...: sdr.plot.impulse_response(h_srrc) ...:
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(); \ ...: sdr.plot.impulse_response(iir, N=30) ...: