Rowan-Classes/8th-Semester-Spring-2025/clinic-consultant/labs/lab-2/lab2q4.py
Aidan Sharpe 82b435b6a2 Week 3
2025-02-14 22:27:10 -05:00

33 lines
492 B
Python

import numpy as np
import matplotlib.pyplot as plt
def u(n):
return np.heaviside(n, 1)
def main():
# Part a
a = np.pi/4
n = np.arange(51)
x = 5*np.cos(a**2 * n)
plt.stem(n, x)
plt.xlabel("$n$")
plt.ylabel(r"$x[n] = 5\cos(a^2 n)$")
plt.show()
# Part b
A = 5
b = (1 + 1j)/2
x = A*np.abs(b)**n * u(n)
plt.stem(n, x)
plt.xlabel("$n$")
plt.ylabel("$x[n] = A|b|^n u(n)$")
plt.show()
if __name__ == "__main__":
main()