Created
July 11, 2020 10:02
-
-
Save itspacchu/8da499ffd33d8d5cf42d4dedede24257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def dft(x): | |
X = [] | |
N = len(x) | |
for k in range(-N,N): | |
re = 0 | |
im = 0 | |
for n in range(0,N): | |
phi = (2*np.pi*k*n)/N | |
re += x[n]*np.cos(phi) | |
im -= x[n]*np.sin(phi) | |
re = re/N | |
im = im/N | |
freq = k | |
mag = abs(complex(re,im)) | |
phase = np.arctan(im/re) | |
X.append([re,im,freq,mag,phase]) | |
return X |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment