Posted: September 13th, 2017

EE-348 Lab

Paper, Order, or Assignment Requirements

 

 

EE 348: Lab 4, Spring 2015 Sampling and Aliasing 1 Introduction Lab 4 examines sampling of a continuous-time signal and how sampling at below the Nyquist frequency can create aliasing in the sampled sequence. This lab counts as a one-week lab. However, you have 2 weeks to work on Lab 4, so it is due 2 weeks from being assigned. Lab 4 is due as follows: • If you are in the Wednesday lab: By the beginning of lab Wednesday, Feb. 25, 2015, for full credit. Late Lab 4: By the beginning of lab the following Wednesday, March 4, for -20% late penalty. If emailed to me by 11:59 PM on the due date, Wednesday, Feb. 25, the late penalty is only -10%. • If you are in the Friday lab: By the beginning of lab Friday, Feb. 27, 2015, for full credit. Late Lab 4: By the beginning of lab the following Friday, March 6, for -20% late penalty. If emailed to me by 11:59 PM on the due date, Friday, Feb. 27, the late penalty is only -10%. Labs are to be done individually, although you may consult together in groups in regards to the lab. It is expected that you will need to spend some time outside of the scheduled lab period to complete and document each lab. 1.1 Lab Goals The primary goals of this lab are: • Determine the Nyquist sampling rate for a continuous-time function x(t) with maximum frequency fmax. • Sample x(t) at two different sampling rates: fs,1 which is above the Nyquist sampling rate of 2fmax, and fs,2 which is below the Nyquist sampling rate. Obtain two sampled sequences x[n] from sampling at fs,1 and fs,2. • Interpolate between samples of x[n] using Matlab’s interp1 function to reconstruct x(t) from the sampled sequence x[n]. • Use linear interpolation and cubic spline interpolation. • Observe that when fs < 2fmax, as in fs,1, aliasing occurs in the sampled sequence x[n] which prevents proper reconstruction of x(t) from x[n]. 2 Nyquist-Shannon Sampling Theorem The Nyquist-Shannon sampling theorem states that a continuous-time band-limited signal x(t) with maximum frequency fmax can be reconstructed exactly from its discrete-time sampled sequence x[n] if the samples are taken at a sampling rate fs > 2fmax. 1EE 348: Lab 4, Spring 2015 2 This condition on the sampling rate is known as the Nyquist sampling criterion fs > 2fmax. (1) The lower bound on the sampling rate, 2fmax, is known as the Nyquist rate. This is equivalent to a condition for the maximum sampling time Ts, such that Ts < 1 2fmax . (2) 2.1 Lab Exercise: Sampling 1. Consider the continuous-time band-limited signal x(t) = cos(50πt) + 2 cos(100πt) + 5 cos(250πt). What is its maximum frequency fmax? What is its period T? 2. Generate a time vector t long enough to show 2 cycles of x(t) above. Use a time step of ∆t = 800µs = 0.8 ms. Your time vector t should start at 0 and end at 2T. Include the Matlab command used to generate t. 3. Now generate 2 cycles of the x(t) given above using your time vector t in the previous step. Call this vector x. Include the Matlab command used to generate x. 4. Plot your vector x (which is your x(t)) vs t, with t on the x-axis and x(t) (x) on the y-axis. Label your plot, save it, and include it in your lab report. This is your ”continuous-time” signal x(t). 5. What is the Nyquist sampling rate for x(t)? What is the corresponding maximum sampling time for reconstruction of x(t)? 6. Let x1[n] be the discrete-time sampled version of x(t) with a sampling time Ts = 1.6ms. Does this correspond to a sampling rate above or below the Nyquist sampling rate? Do you expect to be able to accurately reconstruct x(t) from x1[n]? Include the answers to these questions in your lab report. 7. Generate x1[n] = x(nTs) with Ts = 1.6 ms. You can generate x1[n] either from your Matlab-generated x(t) (by extracting every other sample, since ∆t = 0.8ms and Ts = 2∆t) or from the equation for x(t), using t = nTs. Save your commands to do this in your lab report. 8. Plot x1[n] vs n. Use either stem(x1) or bar(x1) for the best display. If you use plot(x1), Matlab displays a continuous-time plot, using linear interpolation to fill in between the samples. Label your plot, save it, and include it in your lab report. 9. Let x2[n] be the discrete-time sampled version of x(t) with a sampling time Ts = 8ms. Does this correspond to a sampling rate above or below the Nyquist sampling rate? Do you expect to be able to accurately reconstruct x(t) from x2[n]? Include the answers to these questions in your lab report. 10. Generate x2[n] = x(nTs) with Ts = 8 ms. You can generate x2[n] either from your Matlab-generated x(t) (by extracting every 10th sample, since Ts = 10∆t) or from the equation for x(t), using t = nTs. Save your commands to do this in your lab report. 11. Plot x2[n] vs n. Use either stem(x2) or bar(x2) for the best display. If you use plot(x2), Matlab displays a continuous-time plot, using linear interpolation to fill in between the samples. Label your plot, save it, and include it in your lab report.EE 348: Lab 4, Spring 2015 3 3 Aliasing Aliasing occurs with digital sampling of a signal, when the signal contains frequency components higher than half than the sampling rate. The sampling process maps, or aliases, these higher frequency components to lower frequencies within the range of fs/2, the folding frequency. The folding frequency is called such because the higher frequency components are ”folded over” at the folding frequency fs/2 into the lower frequency range (below fs/2. For example, if the sampling rate is 500 Hz, the folding frequency is 250 Hz. A frequency of 450 Hz will be aliased to a frequency of 250 – (450 – 250) Hz = 50 Hz. A frequency of 325 Hz will alias to a frequency 175 Hz, and a frequency of 1000 Hz aliases to a frequency of 0 Hz. 3.1 Lab Exercise: Aliasing 1. What is the folding frequency if Ts = 1.6 ms? Assuming no frequencies greater than 125 Hz, do you expect any aliasing from x1[n]? Explain why or why not. 2. If fmax = 25 Hz, would you expect any aliasing with Ts = 1.6 ms? Explain why or why not. 3. What is the folding frequency for Ts = 8 ms? Assuming no frequencies greater than 125 Hz, do you expect any aliasing from x2[n]? Explain why or why not. 4. If fmax = 25 Hz, would you expect any aliasing with Ts = 8 ms? Explain why or why not. 4 Signal Reconstruction/Interpolation To reconstruct x(t) from the discrete-time samples x[n], some form of interpolation must be used to find values of x(t) at times other than nTs, between the samples. Linear interpolation, drawing a straight line between two samples such that any point between the two samples is chosen to be on that line, is a very simple form of interpolation. When you plot a vector x in Matlab using the plot(x) command, Matlab uses linear interpolation to connect each element of the vector x to its neighboring element in the plot. This gives x the appearance of being continuous, even though it consists of individual samples, the elements of x. Matlab has a command, interp1, which performs interpolation on a discrete sequence y. Interpolation estimates the values of y at points between the existing points in y using different methods. The default method is linear interpolation. The interp1 command needs to know the following things: • A vector of the points where you have samples of y. If the sampled y contains samples taken at every Ts, then this time vector is [0 Ts 2Ts . . . nTs], where nTs is the last time sample taken. Matlab calls this vector X in its help interp1 comments. • The vector of samples of y. For example, this could be your x1[n] or x2[n] in the previous section on Sampling. Matlab calls this vector Y in its help interp1 comments. Vectors X and Y must have the same length. • A vector of the points where you want to have samples of y, but don’t have samples there. These are the points where you want to interpolate y from the existing sampled sequence. This could be your original t vector. You want to interpolate values from your sampled vector to reconstruct the original continuous-time vector. Matlab calls this vector XI in its help interp1 comments.EE 348: Lab 4, Spring 2015 4 The output of interp1 is a vector of the interpolated values of y at each of the points in vector X1. Matlab calls this vector YI in its help interp1 comments. Vector YI will have the same length as vector XI. Matlab’s interp1 command is used as YI = INTERP1(X,Y,XI,’method’); where ’method’ is the type of interpolation method used. If you do not specify a method, linear interpolation is used as the default method. There are several methods available with interp1; ’linear’ and ’spline’ (piecewise cubic spline) are the two methods which we will use in this lab. Both methods will be used to interpolate x(t) from each of the sampled sequences x1[n] and x2[n]. 4.1 Lab Exercise: Interpolation of Sampled Sequence x1[n] 1. Use linear interpolation to interpolate values of x(t) from the sampled sequence x1[n]. The output from the interp1 function will be your linear-interpolated approximation of x(t), which we’ll call x1,l(t). Linear interpolation is indicated in interp1 by using ’linear’ as the method (or by not including the method; linear interpolation is the default interpolation method). Your X vector for the interp1 command is the sampled time vector you used to obtain x1[n], or (if you extracted x1[n] from x(t)) is the time vector [0 Ts 2Ts . . . 2T]. Your X1 vector is your original time vector t. Your Y vector is, of course, your sampled x1[n]. Include your interpolation command in your report. 2. Now use cubic spline interpolation to interpolate values of x(t) from x1[n]. We’ll call the cubic-splineinterpolated output x1,c(t). Cubic spline interpolation is indicated in interp1 by using ’spline’ as the method. Include your interpolation command in your report. 3. Plot both the linear-interpolated x1,l(t) and the cubic-spline-interpolated x1,c(t) on the y-axis versus the original time vector t on the x-axis. Also include in your plot the original x(t) from the Sampling section of this lab. Be sure to use plot, not stem, so that the curves look like continuous-time signals. 4. Use different line styles to distinguish the three curves. There are four continuous line styles: solid line, dashed line, dotted line, and dot-dashed line. The default line style is a solid line. In the plot() command, you can tell Matlab which line style to use with the following arguments: solid line = ’-’ (a hyphen), dashed line = ’–’ (two hyphens), dotted line = ’;’ (semicolon), and a dot-dashed line = ’-.’ (hyphen followed by period). You may also tell Matlab which color to use for each line style, but this is not necessary. The following colors are indicated by: red = ’r’, blue = ’b’, green =’g’, black = ’k’, cyan = ’c’, magenta = ’m’. Yellow is too hard to see, so I don’t recommend using yellow. The default color is blue for the first line. 5. Use a legend to label each of the three curves. Also label the axes. 6. Which interpolation method (linear or cubic spline) provided a curve that looks more like x(t)? Do both curves, x1,l(t) and x1,c(t), provide an acceptable reconstruction of x(t)? Now do the same interpolation, using the sampled sequence x2[n], as indicated in the steps below. 4.2 Lab Exercise: Interpolation of Sampled Sequence x2[n] 1. Use linear interpolation to interpolate values of x(t) from the sampled sequence x2[n]. The output from the interp1 function will be your linear-interpolated approximation of x(t), which we’ll call x2,l(t). Include your interpolation command in your report.EE 348: Lab 4, Spring 2015 5 2. Now use cubic spline interpolation to interpolate values of x(t) from x2[n]. We’ll call the cubic-splineinterpolated output x2,c(t). Include your interpolation command in your report. 3. Plot both the linear-interpolated x2,l(t) and the cubic-spline-interpolated x2,c(t) on the y-axis versus the original time vector t on the x-axis. Also include in your plot the original x(t) from the Sampling section of this lab. Be sure to use plot, not stem, so that the curves look like continuous-time signals. 4. Use different line styles to distinguish the three curves. 5. Use a legend to label each of the three curves. Also label the axes. 6. Which interpolation method (linear or cubic spline) provided a curve that looks more like x(t)? Do both curves, x1,l(t) and x1,c(t), provide an acceptable reconstruction of x(t)? 7. Which sampled sequence, x1[n] or x2[n], provided the best reconstruction of x(t)? Explain why

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Live Chat+1-631-333-0101EmailWhatsApp