sdr.plot.step_response(filter: FIR | IIR | ArrayLike | tuple[ArrayLike, ArrayLike], N: int | None = None, ax: plt.Axes | None = None, type: 'plot' | 'stem' = 'stem', **kwargs)

Plots the step response \(s[n]\) of a filter.

The step response \(s[n]\) is the filter output when the input is a unit step \(u[n]\).

Parameters:
filter: FIR | IIR | ArrayLike | tuple[ArrayLike, ArrayLike]

The filter definition.

  • sdr.FIR, sdr.IIR: The filter object.

  • npt.ArrayLike: The feedforward coefficients \(b_i\).

  • tuple[npt.ArrayLike, npt.ArrayLike]: The feedforward coefficients \(b_i\) and feedback coefficients \(a_j\).

N: int | None = None

The number of samples \(N\) to plot. If None, the length of b is used for FIR filters and 100 for IIR filters.

ax: plt.Axes | None = None

The axis to plot on. If None, the current axis is used.

type: 'plot' | 'stem' = 'stem'

The type of plot to use.

**kwargs

Additional keyword arguments to pass to the plotting function.

Examples

See the FIR filters example.

In [1]: h_srrc = sdr.root_raised_cosine(0.5, 10, 10)

In [2]: plt.figure(); \
   ...: sdr.plot.step_response(h_srrc)
   ...: 
../../_images/sdr_plot_step_response_1.png

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.step_response(iir, N=30)
   ...: 
../../_images/sdr_plot_step_response_2.png