import numpy as np import matplotlib.pyplot as plt Fs = 200 # sampling rate Ts = 1.0/Fs # sampling interval t = np.arange(0, 1, Ts) # time vector f_f = np.arange(30, 80, 0.001) a = np.arange(0, len(f_f), 1) for i in range(len(f_f)): y2 = y2 + np.sin(2 * np.pi * (f_f[i]) * t) n = len(y2) k = np.arange(n) T = n/Fs frq = k/T # two sides frequency range freq = frq[range(int(n/2))] # one side frequency range Y = np.fft.fft(y2)/n # fft computing and normalization #Y = np.fft.fft(y2) Y = Y[range(int(n/2))] plt.plot(freq, abs(Y), 'r-') # Fourier data plt.show()
Here, as you may have noticed I have chosen df = 0.001 and the corresponding DFT is shown in the attached pic. However, while I am considering df = 1 instead, DFT comes out as sort of continuous square wave over the frequency domain of the signal (expected since amplitude of all the waves are equal). Why is it then getting distorted for df = 0.1 or smaller ? I mean why two peaks are appearing at f = 30 Hz & f = 80 Hz and not the entire band ?
Even, sampling rate has been so chosen so that nyquist rate exceeds maximum frequency component of the pulse