Here to do a record, about the FFT will not be introduced, directly attached to the code, there are detailed comments: import numpy as npfrom scipy.fftpack import fft, ifftimport matplotlib.pyplot as pltimport seaborn # sampling points select 1400, because the settings The signal frequency component is up to 600 Hz. According to the sampling theorem, the sampling frequency is greater than 2 times the signal frequency, so the sampling frequency is set to 1400 Hz (that is, there are 1400 sampling points in one second, the same meaning) x=np.linspace (0,1,1400) #Set the signal to be sampled, the frequency components are 180,390 and 600y=7*np.sin(2*np.pi*180*x) + 2.8*np.sin(2*np. Pi*390*x)+5.1*np.sin(2*np.pi*600*x)yy=fft(y) #fast Fourier transform yreal = yy.real # Get the real part yimag = yy.imag # Get the imaginary part yf=abs(fft(y)) # Take the absolute value yf1=abs(fft(y))/len(x) #normalize yf2 = yf1[range(int(len(x)/2) )] # Due to symmetry, only half of the interval xf = np.arange(len(y)) # frequency xf1 = xfxf2 = xf[range(int(len(x)/2))] # half Plt.subplot(221)plt.plot(x[0:50],y[0:50]) plt.title('Original wave')plt.subplot(222)plt.plot(xf,yf,'r ')plt.title('FFT of Mixed wave(two sides frequency range)', fontsize=7,color='#7A378B') #Note that the color here can be queried for the color code table plt.subplot(223)plt.plot( Xf1, yf1, 'g') plt.title('FFT of Mixed wave(normalization)', fontsize=9, color='r')plt.subplot(224)plt.plot(xf2,yf2,'b') Plt.title('FFT of Mixed wave)',fontsize=10,color='#F08080')plt.show()
result:
Add a simple example
# -*- coding: utf-8 -*-import matplotlib.pyplot as pltimport numpy as npimport seabornFs = 150.0; # sampling rate sampling rate Ts = 1.0/Fs; # sampling interval sampling interval t = np.arange(0,1 , Ts) # time vector, where Ts is also the step size ff = 25; # frequency of the signaly = np.sin(2*np.pi*ff*t)n = len(y) # length of the signalk = np. Arange(n)T = n/Fsfrq = k/T # two sides frequency rangefrq1 = frq[range(int(n/2))] # one side frequency rangeYY = np.fft.fft(y) # 未 normalization Y = np.fft.fft(y)/n # fft computing and normalization Normalized Y1 = Y[range(int(n/2))]fig, ax = plt.subplots(4, 1)ax[0] .plot(t,y)ax[0].set_xlabel('Time')ax[0].set_ylabel('Amplitude')ax[1].plot(frq,abs(YY),'r') # plotting the Spectrumax[1].set_xlabel('Freq (Hz)')ax[1].set_ylabel('|Y(freq)|')ax[2].plot(frq,abs(Y),'G') # plotting The spectrumax[2].set_xlabel('Freq (Hz)')ax[2].set_ylabel('|Y(freq)|')ax[3].plot(frq1,abs(Y1),'B') # Plotting The spectrumax[3].set_xlabel('Freq (Hz)')ax[3].set_ylabel('|Y(freq)|')plt.show()
VOZOL BAR 500 Vapes are so convenient, portable, and small volume, you just need to take them
out of your pocket and take a puff, feel the cloud of smoke, and the fragrance of fruit surrounding you. It's so great.
We are China leading manufacturer and supplier of Disposable Vapes puff bars, vozol bar 500 disposable vape,vozol bar 500 vape kit,
vozol bar 500 vape pen, and e-cigarette kit, and we specialize in disposable vapes, e-cigarette vape pens, e-cigarette kits, etc.
vozol bar 500 disposable vape,vozol bar 500 vape kit,vozol bar 500 vape pen,vozol bar 500 vape grape ice,vozol bar 500 Vape blue razz ice
Ningbo Autrends International Trade Co.,Ltd. , https://www.supervapebar.com