Guest User

Untitled

a guest
Dec 16th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import numpy
  2. from matplotlib import pyplot
  3.  
  4. ## Replace with your own samples and rate
  5. samples = …
  6. sampling_rate = 32e3
  7.  
  8. ## Do a fourier transform of the whole data set
  9. fourier_transform = numpy.fft.fft(samples)
  10. positive_freq_components = fourier_transform[0:len(fourier_transform) / 2]
  11. positive_freq_components_mag_squared = numpy.abs(positive_freq_components)**2
  12. frequencies = numpy.linspace(0, sampling_rate / 2, len(fourier_transform) / 2)
  13.  
  14. ## Plot that stuff!
  15. pyplot.plot(frequencies, positive_freq_components_mag_squared)
  16. pyplot.xlabel("Frequency (Hz)")
  17. pyplot.ylabel("Digital Power")
  18. pyplot.tight_layout()
  19. pyplot.show()
Add Comment
Please, Sign In to add comment