Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from scipy.fftpack import fft
- import numpy as np
- from scipy import pi
- import matplotlib.pyplot as plt
- %matplotlib inline
- # Sampling rate and time vector
- start_time = 0 # seconds
- end_time = 2 # seconds
- sampling_rate = 6660 # Hz
- N =(end_time - start_time)*sampling_rate # array size
- # Nyquist Sampling Criteria
- T = 1/sampling_rate # inverse of the sampling rate
- x = np.linspace(0.0, 1.0/(2.0*T), int(N/2))
- # FFT algorithm
- yr = fft(X) # "raw" FFT with both + and - frequencies
- y = 2/N * np.abs(yr[0:np.int(N/2)]) # positive freqs only
- # Plotting the results
- plt.plot(x, y)
- plt.xlabel('Frequency (Hz)')
- plt.ylabel('Vibration (g)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement