Plotting cross-spectral density in Python using Matplotlib
Matlplotlib is a comprehensive library consisting of modules that are used for Data Visualization just like MATLAB. Pyplot is a further module which makes functions and methods executable.
Plotting Cross-Spectral Density
The cross-spectral density compares two signals, each from different source taking into account both amplitude and phase difference of the two signals. In Python, this function is carried out using the Pyplot module’s method
Here, x and y are 1-D arrays or a sequence having the data.
Let us take two signals and plot their CSD:
- Signal 1 has time period from 0 to 1 second and 0.1 radian phase angle with frequency being calculated using
- Similarly, Signal 2 has time period from 5 to 10 seconds and 0.25 radians phase angle.
- Taking these two signals, we plot their cross spectral density.
Example 1: Plotting Signal 1
Example 2: Plotting Signal 2
Example 3: Plotting the cross-spectral density
Example 4: Using discrete lists or arrays
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course