36 lines
981 B
Python
36 lines
981 B
Python
"""
|
|
ECE 09351 - Digital Signal Processing
|
|
Lab 1 Question 1
|
|
|
|
Translated from MATLAB by Aidan Sharpe
|
|
Last Modified: January 16, 2025
|
|
"""
|
|
|
|
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
def main():
|
|
f_s = 100 # Sample frequency [Hz]
|
|
T_s = 1/f_s # Sample period [s]
|
|
|
|
n = np.arange(10) # Samples starting at zero, up to, but not including 10
|
|
t = n*T_s # Convert from sample domain to time domain
|
|
|
|
x_20 = np.cos(2*np.pi*20*t) # Cosine signal x[n] with f = 20[Hz]
|
|
x_80 = np.cos(2*np.pi*80*t) # Cosine signal x[n] with f = 80[Hz]
|
|
|
|
plt.subplot(211) # Begin top subplot
|
|
plt.stem(n, x_20) # Plot samples of x (x_20) over sample indicies (n)
|
|
plt.subplot(212) # Begin bottom subplot
|
|
plt.stem(n, x_80) # Plot samples of x (x_80) over sample indicies (n)
|
|
|
|
plt.show() # Show the plot
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|