-
sdr.plot.correlation(x: ArrayLike, y: ArrayLike, sample_rate: float | None =
None, mode: 'full' | 'valid' | 'same' | 'circular' ='full', ax: Axes | None =None, y_axis: 'complex' | 'mag' | 'mag^2' | 'db' ='mag', diff: 'color' | 'line' ='color', **kwargs) Plots the correlation between two time-domain signals \(x[n]\) and \(y[n]\).
- Parameters:¶
- x: ArrayLike¶
The first time-domain signal \(x[n]\).
- y: ArrayLike¶
The second time-domain signal \(y[n]\).
- sample_rate: float | None =
None¶ The sample rate \(f_s\) of the signal in samples/s. If
None, the x-axis will be labeled as “Lag (samples)”.- mode: 'full' | 'valid' | 'same' | 'circular' =
'full'¶ The
numpy.correlate()correlation mode. If"circular", a circular correlation is computed using FFTs.- ax: Axes | None =
None¶ The axis to plot on. If
None, the current axis is used.- y_axis: 'complex' | 'mag' | 'mag^2' | 'db' =
'mag'¶ Indicates how to plot the y-axis. If
"complex", the real and imaginary parts are plotted separately.- diff: 'color' | 'line' =
'color'¶ Indicates how to differentiate the real and imaginary parts of a complex signal. If
"color", the real and imaginary parts will have different colors based on the current Matplotlib color cycle. If"line", the real part will have a solid line and the imaginary part will have a dashed line, and both lines will share the same color.- **kwargs¶
Additional keyword arguments to pass to
matplotlib.pyplot.plot().
Examples
Plot the auto-correlation of a length-63 \(m\)-sequence. Notice that the linear correlation produces sidelobes for non-zero lag.
In [1]: x = sdr.m_sequence(6, output="bipolar") In [2]: plt.figure(); \ ...: sdr.plot.correlation(x, x, mode="full"); ...:
However, the circular correlation only produces magnitudes of 1 for non-zero lag.
In [3]: plt.figure(); \ ...: sdr.plot.correlation(x, x, mode="circular"); ...: