Skip to content

Instantly share code, notes, and snippets.

@gustheman
Created March 8, 2023 15:42
Show Gist options
  • Save gustheman/0d2f54ed1d6c777dab3f25f0e6cda075 to your computer and use it in GitHub Desktop.
Save gustheman/0d2f54ed1d6c777dab3f25f0e6cda075 to your computer and use it in GitHub Desktop.
Plotting frequencies
import matplotlib.pyplot as plt
import tensorflow as tf
n = len(x)
T = 1/samples
yf = tf.signal.fft(ys)
xf = np.linspace(0.0, 1.0/(2.0*T), int(n/2))
plt.plot(xf, 2.0/n*np.abs(yf[:n//2]))
plt.title('Spectrum')
plt.xlabel('Frequency Bin')
plt.ylabel('Amplitude')
plt.grid()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment