Rowan-Classes/6th-Semester-Spring-2024/DSP/Labs/Lab-02/lab-02-2.py
2024-02-23 21:42:45 -05:00

38 lines
584 B
Python

import numpy as np
import matplotlib.pyplot as plt
PI = np.pi
f_s1 = 1
f_s2 = 2.5
f_s3 = 3
f_s4 = PI
t1 = np.arange(0,40,1/f_s1)
t2 = np.arange(0,40,1/f_s2)
t3 = np.arange(0,40,1/f_s3)
t4 = np.arange(0,40,1/f_s4)
x1 = np.cos(2*PI*t1/7)
x2 = np.cos(2*PI*t2/7)
x3 = np.cos(2*PI*t3/7)
x4 = np.cos(2*PI*t4/7)
plt.subplot(2,2,1)
plt.stem(t1,x1)
plt.title("1[Hz] Sampling")
plt.subplot(2,2,2)
plt.stem(t2,x2)
plt.title("2.5[Hz] Sampling")
plt.subplot(2,2,3)
plt.stem(t3,x3)
plt.title("3[Hz] Sampling")
plt.subplot(2,2,4)
plt.stem(t4,x4)
plt.title("$\pi$[Hz] Sampling")
plt.show()