Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. from scipy.fftpack import fft
  2. import numpy as np
  3. from scipy import pi
  4. import matplotlib.pyplot as plt
  5. %matplotlib inline
  6.  
  7. # Sampling rate and time vector
  8. start_time = 0 # seconds
  9. end_time = 2 # seconds
  10. sampling_rate = 6660 # Hz
  11. N =(end_time - start_time)*sampling_rate # array size
  12.  
  13. # Nyquist Sampling Criteria
  14. T = 1/sampling_rate # inverse of the sampling rate
  15. x = np.linspace(0.0, 1.0/(2.0*T), int(N/2))
  16.  
  17. # FFT algorithm
  18. yr = fft(X) # "raw" FFT with both + and - frequencies
  19. y = 2/N * np.abs(yr[0:np.int(N/2)]) # positive freqs only
  20.  
  21. # Plotting the results
  22. plt.plot(x, y)
  23. plt.xlabel('Frequency (Hz)')
  24. plt.ylabel('Vibration (g)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement