6th Semester Files
This commit is contained in:
23
6th-Semester-Spring-2024/DSP/Labs/Lab-02/lab-02-5.py
Normal file
23
6th-Semester-Spring-2024/DSP/Labs/Lab-02/lab-02-5.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def x(n):
|
||||
return (1/n) * np.heaviside(n, 0.5)
|
||||
|
||||
n = np.arange(1,100)
|
||||
|
||||
y = x(n)
|
||||
|
||||
E_x_total = 0
|
||||
E_x = np.zeros(len(y))
|
||||
|
||||
for i in range(len(y)):
|
||||
E_x_total += abs(y[i])**2
|
||||
E_x[i] = E_x_total
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
ax.scatter(n,y, label="x[n]")
|
||||
ax.scatter(n, E_x, c='red', label="E_x")
|
||||
ax.axhline(np.pi**2 / 6, linestyle='-')
|
||||
ax.legend()
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user