Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import scipy.signal as signal
  4.  
  5.  
  6.  
  7. def plot_spectrogram(data,NFFT,Fs,ex ):
  8. plt.specgram(data, NFFT=NFFT, Fs=Fs)
  9. plt.title("Spectrogram of data")
  10. plt.ylim(-Fs/2, Fs/2)
  11. plt.show()
  12. plt.close()
  13.  
  14. if ex:
  15. exit()
  16.  
  17.  
  18. ### Parameters
  19. F_offset = 250000
  20. Fs = 1140000
  21.  
  22. ### Generate a digital complex exponential with phase -F_offset/Fs
  23. fc1 = np.exp(-1.0j*2.0*np.pi* F_offset/Fs*np.arange(len(x1)) )
  24. plot_spectrogram(fc1, 512, Fs,ex=True)
  25.  
  26. plt.plot(20*np.log10(np.abs(np.fft.fft(fc1[:512]*np.hanning(512)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement