DSP lab 4 part 1 done

This commit is contained in:
2024-04-17 20:02:38 -04:00
parent 9aa8810f92
commit df7d52f4b1
14 changed files with 165 additions and 62 deletions

View File

@@ -4,21 +4,36 @@ import matplotlib.pyplot as plt
N = 8
# Analytic DFT
'''
k = np.arange(N)
W_N = np.exp(-2j*np.pi*k/N)
plt.stem(k, -W_N)
plt.xlabel("$k$")
plt.ylabel("$W_N$")
plt.show()
'''
# N=8
n = np.arange(N)
x = (-1.0)**n
# 8-point DFT, N=8
DFT_8_point = np.fft.fft(x, 8)
DFT_9_point = np.fft.fft(x, 9)
plt.stem(abs(DFT_8_point))
plt.show()
plt.savefig("N8_point_dft.png")
plt.close()
# 9-point DFT, N=8
DFT_9_point = np.fft.fft(x, 9)
plt.stem(abs(DFT_9_point))
plt.savefig("Q9_point_dft.png")
plt.close()
# 9-point DFT, N=9
N = 9
n = np.arange(N)
x = (-1.0)**n
DFT_9_point = np.fft.fft(x, 9)
plt.stem(abs(DFT_9_point))
plt.savefig("N9_point_dft.png")
plt.show()