Power Electronics notes from March 19th
This commit is contained in:
27
6th-Semester-Spring-2024/DSP/Labs/Lab-03/lab-03-1.py
Normal file
27
6th-Semester-Spring-2024/DSP/Labs/Lab-03/lab-03-1.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
n = np.arange(0,200)
|
||||
|
||||
a = 0.9
|
||||
|
||||
# x[n] = a^n u[n]
|
||||
x = a**n * np.heaviside(n, 1)
|
||||
|
||||
asums = np.zeros(len(n))
|
||||
|
||||
for i in range(len(n)):
|
||||
asums[i] = np.sum(x[0:i])
|
||||
|
||||
# Plot settings for $x[n]$
|
||||
plt.subplot(121)
|
||||
plt.plot(n, x)
|
||||
plt.xlabel("$n$")
|
||||
plt.ylabel("$x[n]$", rotation="horizontal")
|
||||
|
||||
# Plot settings for sum of $x[n]$
|
||||
plt.subplot(122)
|
||||
plt.plot(n, asums)
|
||||
plt.xlabel("$n$")
|
||||
plt.ylabel("$\sum_n x[n]$", rotation="horizontal")
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user