signal = [] signal = np.zeros((N, 3), dtype='complex') fftsignal = [] fftsignal = np.zeros((N, 3), dtype='complex') fftsignal1 = [] fftsignal1 = np.zeros((N, 3), dtype='complex') tt, signal[:, 0] = sg.seno(fs, f0, N, a0, p0) tt, signal[:, 1] = sg.square(fs, f0, N, a0, p0, duty) tt, signal[:, 2] = sg.sawtooth(fs, f0, N, a0, p0, width) ii = 0 while ii < 3: fftsignal[:, ii] = np.fft.fft(signal[:, ii]) FFT.plotFFT(fftsignal[:, ii], fs, N, tp='FFT', c=ii, db='off', l=lsignal[ii]) fftsignal1[:, ii] = FFT.myDFT(signal[:, ii]) FFT.plotFFT(fftsignal1[:, ii], fs, N, tp='DFT', c=ii, db='off', l=lsignal[ii]) ii += 1
ii = 0 while ii < 8: tt, signal = sg.seno(fs, f0, N[ii], a0, p0) the_start = time() np.fft.fft(signal) the_end = time() tiempofft[ii] = the_end - the_start ii += 1 #%% calculando el tiempo de mi DFT ii = 0 while ii < 8: tt, signal = sg.seno(fs, f0, N[ii], a0, p0) the_start = time() FFT.myDFT(signal) the_end = time() tiempodft[ii] = the_end - the_start ii += 1 import pandas as pd index = ['16', '32', '64', '128', '256', '512', '1024', '2048', '4096', '8192'] data = {'N': index, 'FFT': tiempofft, 'myDFT': tiempodft} df = pd.DataFrame(data) df.set_index('N', inplace=True) # select two columns print(df) plt.figure("Gráfico comparatvo de tiempo entre la FFT y la DFT")