Problem 3 (b) from preparation exercises for partial exam 2

Sampling of a 60Hz sinusoidal noise signal


In [9]:
%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import Math

h = 0.25 # Sampling time
ws = 2*np.pi/h
wN = ws/2
w1 = 120*np.pi
w1Alias = np.abs( (w1+wN) % ws - wN)  # 0
print w1Alias

T = 2*np.pi/w1 # Period of sinusoid

t = np.linspace(0,30*T, 1200)
y1 = np.cos(w1*t)
ya = np.cos(w1Alias*t)

ts = np.arange(3)*h
y1Sampled = np.cos(w1*ts)
yaSampled = np.cos(w1Alias*ts)

plt.figure()
plt.plot(t, y1, 'b')
plt.plot(t, ya, 'r')
plt.plot(ts, y1Sampled, 'bo', markersize=10)
plt.stem(ts, yaSampled, linefmt='r--', markerfmt='ro', basefmt = 'r-')
plt.xlabel('t [seconds]')
plt.xlim(-0., 0.5)
plt.ylim(-1.2, 1.2)

plt.show()


1.42108547152e-14

In [ ]:


In [ ]: