Finished ECOMMS homework 3
This commit is contained in:
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab1/dft.png
Normal file
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab1/dft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
@ -2,10 +2,9 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import scipy as sp
|
||||
|
||||
f_s = 8E3
|
||||
|
||||
f_s = 10
|
||||
T_s = 1/f_s
|
||||
t = np.arange(-5,5,T_s)
|
||||
t = np.arange(0,1+T_s,T_s)
|
||||
|
||||
f = np.linspace(0,f_s,len(t))
|
||||
omega = 2*np.pi*f
|
||||
@ -18,16 +17,9 @@ w = u(t) - u(t-0.6) + u(t-0.7) - u(t-1)
|
||||
W_c = 1j*(np.exp(-1j*omega*0.6) + np.exp(-1j*omega) - np.exp(-1j*omega*0.7) - 1)/omega
|
||||
W_d = sp.fft.fft(w)
|
||||
|
||||
print(W_c[:10])
|
||||
print(W_d[:10])
|
||||
|
||||
|
||||
plt.plot(t,w)
|
||||
plt.stem(f, W_d)
|
||||
plt.xlabel("Frequency (Hz)")
|
||||
plt.show()
|
||||
|
||||
|
||||
plt.subplot(211)
|
||||
plt.plot(W_c)
|
||||
plt.subplot(212)
|
||||
plt.plot(W_d)
|
||||
plt.bar(t, sp.fft.ifft(W_d), T_s, align='edge')
|
||||
plt.xlabel("Time (s)")
|
||||
plt.show()
|
||||
|
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab1/recovered_bar.png
Normal file
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab1/recovered_bar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.6 KiB |
Reference in New Issue
Block a user