Skip to content

Commit 6c5f3d0

Browse files
committed
2章を追加 q06,q10についてはうまくいっていないため修正予定
1 parent de5a60a commit 6c5f3d0

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

kkoiso/chapter02/q01.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np
2-
import matplotlib.pyplot as plt
32
def DFT(x):
43
N = len(x)
54
X = [0] * N

kkoiso/chapter02/q02.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
2-
import matplotlib.pyplot as plt
3-
from q01 import DFT,IDFT
2+
from q01 import DFT
43

54
x = np.array([1, 0, 0, 0, 0, 0, 0, 0])
65
X = DFT(x)

kkoiso/chapter02/q03.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
plt.xlabel('Sample')
1818
plt.ylabel('Amplitude')
1919

20-
20+
#虚部をプロット
2121
plt.subplot(2, 1, 2)
2222
plt.stem(idft_imag)
2323
plt.title('IDFT Result (Imaginary Part)')

kkoiso/chapter02/q04.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import numpy as np
22
import matplotlib.pyplot as plt
3-
from q01 import DFT,IDFT
3+
from q01 import DFT
44

55
x = np.array([1, 0, 0, 0, 0, 0, 0, 0])
66
X = DFT(x)
77
title = "DFT impulse"
88

99
plt.figure(figsize=(10, 4))
10+
11+
#振幅スペクトルのプロット
1012
plt.subplot(2, 1, 1)
1113
plt.plot(np.abs(X))
1214
plt.title(title + ' Amplitude Spectrum')
1315
plt.xlabel('Frequency')
1416
plt.ylabel('Amplitude')
1517
plt.grid(True)
1618

19+
#位相スペクトルのプロット
1720
plt.subplot(2, 1, 2)
1821
plt.plot(np.angle(X))
1922
plt.title(title + ' Phase Spectrum')

kkoiso/chapter02/q05.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import numpy as np
22
import matplotlib.pyplot as plt
3-
from q01 import DFT,IDFT
3+
from q01 import DFT
44

55
x = np.array([1, 0, 0, 0, 0, 0, 0, 0])
66
X = DFT(x)
77

88

99
np_X = np.fft.fft(x)
10-
print("Custom DFT:", X)
10+
print("q02 DFT:", X)
1111
print("Np FFT:", np_X)

0 commit comments

Comments
 (0)