Homework 7


Due: Mar 16 by 11:59 pm eastern standard time

Submit a single file called name_07.py to Brightspace/OWL where name is replaced with your last name, e.g. gribble_07.py


Signal Processing Exercises

Here is some Python code to generate a complex signal composed of sinusoids at several frequencies. The signal is sampled at 1000 Hz.

import numpy as np
t = np.arange(0, 0.5, 1/1000)  # 500 ms of time at 1000 Hz
y1 = np.sin(2*np.pi*30 * t)    # pure sinusoid at  30 Hz
y2 = np.sin(2*np.pi*125 * t)   # pure sinusoid at 125 Hz
y3 = np.sin(2*np.pi*300 * t)   # pure sinusoid at 300 Hz
y = y1 + (0.8*y2) + (0.9*y3)
  1. Plot the signal y in the time domain. Label the axes and include a title.
  2. Plot the magnitude spectrum of y using the scipy.signal.welch() function. Label the axes and include a title.
  3. Highpass filter the signal to remove the 30 Hz component. Plot the filtered signal in the time domain and also plot the magnitude spectrum of the filtered signal. Label the axes and include a title.
  4. Lowpass the filtered signal from 3. to remove the 300 Hz component. Plot the filtered signal in the time domain and also plot the magnitude spectrum of the filtered signal. Label the axes and include a title.