Finished ECOMMS homework 3

This commit is contained in:
Aidan Sharpe
2024-11-11 19:15:36 -05:00
parent 660744cf30
commit 655a0ecfde
6 changed files with 43 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -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()

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB