Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- If it will be helpful, please like this post
- """
- Fs = 1024
- sampling_rate = 100 #signal freq
- N = int(Fs / sampling_rate) #number of samples
- t_step = 1 / Fs
- t = np.linspace(0, (N - 1) * t_step, N) #time interval
- freq = Fs / N #freq step
- f = np.linspace(0, (N - 1) * freq, N) # freq interval
- data = np.sin(2 * np.pi * sampling_rate * t)
- fureir = scipy.fft.fft(data)
- fureier_abs = abs(fureir / N)
- data_spec = f[0 : int(N / 2 + 1)]
- furier_abs_plot = 2 * fureier_abs[0 : int(N / 2 + 1)]
- fureier_abs[0] /= 2
- fig, [ax1, ax2] = plt.subplots(nrows=2, ncols=1)
- ax1.plot(t, data)
- ax2.plot(data_spec, furier_abs_plot)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement