30 lines
503 B
Python
30 lines
503 B
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
# Set up N=8
|
|
N = 8
|
|
n = np.arange(N)
|
|
x = (-1.0)**n
|
|
|
|
# 8-point DFT, N=8
|
|
DFT_8_point = np.fft.fft(x, 8)
|
|
plt.stem(abs(DFT_8_point))
|
|
plt.savefig("N8_point_dft.png")
|
|
plt.show()
|
|
|
|
# 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.show()
|
|
|
|
# 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()
|