Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy
- from matplotlib import pyplot
- ## Replace with your own samples and rate
- samples = …
- sampling_rate = 32e3
- ## Do a fourier transform of the whole data set
- fourier_transform = numpy.fft.fft(samples)
- positive_freq_components = fourier_transform[0:len(fourier_transform) / 2]
- positive_freq_components_mag_squared = numpy.abs(positive_freq_components)**2
- frequencies = numpy.linspace(0, sampling_rate / 2, len(fourier_transform) / 2)
- ## Plot that stuff!
- pyplot.plot(frequencies, positive_freq_components_mag_squared)
- pyplot.xlabel("Frequency (Hz)")
- pyplot.ylabel("Digital Power")
- pyplot.tight_layout()
- pyplot.show()
Add Comment
Please, Sign In to add comment