Asked by vinaykathiria

# DSP First Lab 2 (Chapters 4 and 5) handout Similar to DSP First Lab...

**DSP First Lab 2 (Chapters 4 and 5) handout**

Similar to DSP First Lab 1 this will be an individual assignment that will be uploaded to Canvas. Please submit your MATLAB script (.m file) that has comments so that each problem is clearly commented within your MATLAB script file.

**1. (30 points) Concepts of oversampling, under sampling, and stem plotting, chapter 4**

A continuous sinusoidal signal, x(t) = cos(200πt), can be sampled into a discrete signal, x[n]=x(nTs) = cos(2π(100)nTs) with a sampling period of Ts. Please use different colors to plot the following 3 graphs in one figure:

a) Plot the original sinusoidal signal in 3 periods using solid type with black color. (10 points)

b) Use stem plot function to plot a sampled digital signal with Ts = 2ms, using circle type with blue color. (10 points)

c) Use stem plot function to plot a sampled digital signal with Ts = 9ms, using circle type with red color. (10 points)

**[Examples of plotting sinusoids and stem plots were given in examples 1 and 2 in Instruction]**

**2. (30 points) Aliasing, Nyquist rate, principal alias and ideal reconstruction, chapter 4**

Let's start with the same continuous sinusoidal signal, x(t) = cos(200πt), which was given in Problem 1. Now please solve the following problems, and plot the two graphs in one figure and 3 periods again:

a) Stem plot the sampled digital signal, x(nTs) = cos(2π(100)nTs) with Ts = 9ms and Ts = 2ms in one figure. __This is a repeat of b) and c) in Problem 1__.

b) Reconstruct a sinusoidal signal, y(t) = cos(2π(f_{y})t), using Ts = 9ms in a). Please solve f_{y} (5 points), and plot y(t) in the same figure (5 points).

c) Reconstruct a sinusoidal signal, y(t) = cos(2π(f_{y})t), using Ts = 2ms in a). Solve f_{y} (5 points), and plot y(t) in the same figure (5 points).

d) Discuss the consequence of under sampling based on the results from b) and c). (10 points)

**3. (40 points) Add high-frequency and low-frequency noise into an ECG signal, then implement high-pass and low-pass filters to remove the noise from the signal. **

Let's start with an ECG signal:

a) Import the *ECG.mat* into MATLAB using *load()* function.

b) For the given ECG signal, add a very high frequency cosine signal *noise1=2*cos(2*pi*300*t)* and a low frequency cosine signal noise, which is *noise2=2*cos(2*pi*2.5*t)*. Now let *ECGwithnoise= ECG+noise1+noise2*. (5 points)

c) Plot 2 signals in one figure, including the original ECG signal and the one with the two noise signals added. (5 points)

d) Implement a low-pass filter to the noisy ECG signal (*ECGwithnoise*), please use *fir1()* function with parameter Wn=0.4 and order number N=300 to generate your filter. (10 points)

e) Plot the signal after low-pass filtering (hint: use *filtfilt()* function). (15 points)

f) Implement a high-pass filter to the filtered signal from b), please use *fir1()* function with parameter Wn=0.015 and order number N=300 to generate your filter. (10 points)

g) Plot the signal after high-pass filtering. (hint: use *filtfilt()* function again). (5 points)

Noisy ECG signal Low-pass filter High-pass filter Filtered signal

**[Examples of high-pass and low-pass filtering were given in example 3 in Instruction]**

Unlock full access to Course Hero

Explore over 16 million step-by-step answers from our library

Get answerOur verified expert tutors typically answer within 15-30 minutes.