# [Solution]Signal Resampling

ECE334 Discrete Signals and Systems Laboratory Project – Signal Resampling   1 Problem Description: In this laboratory project we are going to change the effective…

ECE334 Discrete Signals and Systems Laboratory Project – Signal Resampling

1 Problem Description:
In this laboratory project we are going to change the effective sampling rate of a discrete signal in order to directly observe the effects of the process both in the frequency domain and after continuous signal reconstruction. We will then design proper decimation and interpolation filters to ensure that the resampling process is completed successfully.
2 Project Definition:
The Sampling Theorem tells us that to properly sample a continuous-time signal that we must sample at a rate greater than or equal to the Nyquist rate, i.e., twice the highest frequency present in the signal. As long as we abide by this rule we can prevent aliasing in our signal.
At times, however, it may be necessary to change the sampling rate of our signal. For example, the input to a given system (over which we have no control) may require signals with specified sampling rates that do not match the sampling rate of our signal. As we learned in class, changing the effective sampling rate is possible, but poses some challenges and care must be taken to ensure we prevent aliasing/spectral replicas from appearing in our resampled signal. We thus found that in order to properly resample our signal we must apply either a decimation filter (in the case of down-sampling) or an interpolation filter (in the case of up-sampling) to ensure that the re-sampling process avoids these problematic scenarios. We also learned that it is possible to re-sample our signal to fractional rates by applying a rate change filter in between the up- and down-sampling process. Each of these resampling methods are shown in the block diagrams below.
Recall that M is the down-sampling factor, L is the up-sampling factor, hd[n] = sinc(πn/M) is the decimation filter, hi[n] = Lsinc(πn/L) is the interpolation filter, and h[n] = sinc(πn/ max(L,M)) is the rate change filter. For this laboratory project, our continuous-time input signal is
x(t) = sin(400πt) + sin(800πt) + sin(2400πt).
We are going to sample the signal at a rate of fs = 3000 Hz. This gives a sampling period of Ts = 1/3000 seconds. We will then reconstruct x(t) multiple times under different resamplings using the MATLAB function reconstruct that I provide (this is provided as an attachment to the assignment on Isidore).
1

For each task you are expected to generate a plot for inclusion in a document that you will submit electronically for this project. Be sure to properly label your figures to receive full credit.
1. For the continuous-time signal x(t):
a. Create the signal x(t) in MATLAB using a time vector, t, that has 1024 samples over four periods of the signal, beginning at t = 0 seconds. Plot x(t) as subplot(2,1,1) of Figure 1.
b. Plot the magnitude response, |X(ejω)|. Generate the magnitude response by applying the DFT using N = 4096, i.e., X = abs(fftshift(fft(x,4096))). Plot this as a function of analog frequency to ensure that the sinusoids are at the expected frequencies. This can be accomplished by first creating the plot vector for w = linspace(−pi,pi,4096) and then scaling it by 1
2π∆t , where ∆t
is the difference between adjacent samples in your continuous-time vector, t, from part a., i.e., dt = t(2) −t(1). Plot the resulting magnitude response as subplot(2,1,2) in Figure 1.
2. Now, we are going to sample x(t) at the specified sampling rate fs and then reconstruct it. To do so:
a. Define a sample vector of n = 0 : 256. Then, generate x[n] = x(nTs). Plot x[n] as a function of n as subplot(3,1,1) of Figure 2.
b. Plot the magnitude response, |X(ejω)|. Generate the magnitude response by applying the DFT using N = 4096. Plot this as a function of digital frequency in radians/sample from ω = [−π,π]. Plot the resulting magnitude response as subplot(3,1,2) in Figure 2.
c. Now, reconstruct x(t) from its samples x[n] using the provided reconstruction function, i.e., [xr,tr] = reconstruct(xn,n,fs), where xn are the samples x[n], fs is the sampling rate fs, xr is the reconstructed continuous-time signal xr(t), and tr is the corresponding continuous-time time vector, tr. Plot the resulting reconstructed signal xr(t) as a function of tr as subplot(3,1,3) in Figure 2.
3. Now, we are going to down-sample x[n] by a factor of M = 2 and then reconstruct it. To do so:
a. Define a sample vector of nds = 0 : length(n)/2. Then, downsample the signal according to x ds = xn(1 : 2 : end). Plot xds[n] as a function of nds as subplot(3,1,1) of Figure 3.
b. Plot the magnitude response, |Xds(ejω)| for N = 4096 from ω = [−π,π] as subplot(3,1,2) in Figure 3.
c. Now, reconstruct xrds (t) from its samples xds[n] using the provided reconstruction function, i.e., [xr ds,tr ds] = reconstruct(xn ds,nds,fs/2). Plot the resulting reconstructed signal xrds (t) as a function of trds as subplot(3,1,3) in Figure 3.
4. Now, we are going to up-sample x[n] by a factor of L = 3 and then reconstruct it. To do so:
a. Define a sample vector of nus = 0 : 3∗length(n) −1. First, zero-initialize the upsample vector, i.e., x us = 0∗nus. Then, upsample the signal according to x us(1 : 3 : end) = xn. Plot xus[n] as a function of nus as subplot(3,1,1) of Figure 4.
b. Plot the magnitude response, |Xus(ejω)| for N = 4096 from ω = [−π,π] as subplot(3,1,2) in Figure 4.
c. Now, reconstruct xrus (t) from its samples xus[n] using the provided reconstruction function, i.e., [xr us,tr us] = reconstruct(xn us,nus,3∗fs). Plot the resulting reconstructed signal xrus (t) as a function of trus as subplot(3,1,3) in Figure 4.
5. Now, we are going to apply a decimation filter to x[n] in order to properly band-limit the signal before down-sampling. To do so:
a. We first define our decimation filter by creating the sample vector m = −25 : 25. Then, we create an ideal decimation filter using hde = sinc(m/2). Then, we normalize the filter so that all terms sum to 1, i.e., hde = hde./(sum(hde)). Now, we apply the decimation filter via convolution, i.e., x de = conv(xn,hde,′ same′), to properly decimate x[n].
2

b. We next repeat step 3.a to down-sample the decimated version of x[n]. Plot xde[n] as a function of nds as subplot(3,1,1) of Figure 5.
c. Plot the magnitude response, |Xde(ejω)| for N = 4096 from ω = [−π,π] as subplot(3,1,2) in Figure 5.
d. Now, reconstruct xrde (t) from its samples xde[n] using the provided reconstruction function, i.e., [xr de,tr de] = reconstruct(xn de,nds,fs/2). Plot the resulting reconstructed signal xrde (t) as a function of trde as subplot(3,1,3) in Figure 5.
6. Now, we are going to apply an interpolation filter to xus[n] in order to properly filter out all spectral replicas from the signal after up-sampling. To do so:
a. We first define our interpolation filter by creating the sample vector m = −25 : 25. Then, we create an ideal interpolation filter using hin = sinc(m/3). Then, we normalize the filter so that all terms sum to L = 3, i.e., hin = 3∗hin./(sum(hin)). b. We next use the previously up-sampled signal from step 4.a, xus[n]. Then, we apply the interpo- lation filter via convolution, i.e., x in = conv(xus,hin,′ same′), to properly interpolate xus[n]. Plot xin[n] as a function of nus as subplot(3,1,1) of Figure 6.
c. Plot the magnitude response, |Xin(ejω)| for N = 4096 from ω = [−π,π] as subplot(3,1,2) in Figure 6.
d. Now, reconstruct xrin (t) from its samples xin[n] using the provided reconstruction function, i.e., [xr in,tr in] = reconstruct(xn in,nus,3∗fs). Plot the resulting reconstructed signal xrin (t) as a function of trin as subplot(3,1,3) in Figure 6.
7. Finally, we are going to change the sampling rate of our signal by the fractional rate of 2 3 .
a. In this case we need to define our rate-change filter to have a cutoff of π max(2,3)
. To perform the
rate-change we first up-sample the signal by a factor of 3 and apply the rate-change filter. Notice that this step results in the same interpolated signal as obtained in 6.b. Thus, to finish the rate change we simply need to downsample xrin (t) by a factor of 2. Thus, x rc = x in(1 : 2 : end) and the sample vector is nrc = 0 : length(x rc) −1. Plot xrc[n] as a function of nrc as subplot(3,1,1) of Figure 7.
c. Plot the magnitude response, |Xrc(ejω)| for N = 4096 from ω = [−π,π] as subplot(3,1,2) in Figure 7.
d. Now, reconstruct xrrc (t) from its samples xrc[n] using the provided reconstruction function, i.e., [xr rc,tr rc] = reconstruct(xn rc,nrc, (2/3) ∗fs). Plot the resulting reconstructed signal xrrc (t) as a function of trrc as subplot(3,1,3) in Figure 7.
3

4 Questions:
Use the generated figures to help answer the following questions. Please include your plots and the answer to the following questions in the form of a .pdf document for online submission through the course website.
1. Determine the Nyquiest rate for x(t):
2. For the given sampling rate fs = 3000Hz, what are the digital frequencies of each sine term?
3. For |X(ω)| in Figure 1, do the delta function terms appear at the expected analog frequencies? Does the DFT result in perfect delta functions?
4. For the sampled signal of Figure 2, does it appear that the signal was properly sampled? Do the delta function terms appear at the expected digital frequencies? Discuss this in regards to both the frequency domain and the reconstructed signal results.
5. For the down-sampled signal of Figure 3, does it appear that down-sampling the signal has resulted in any aliasing? Discuss this in regards to both the frequency domain and the reconstructed signal results.
6. For the up-sampled signal of Figure 4, does it appear that up-sampling the signal has resulted in any spectral replicas moving into the [−π,π] window? Discuss this in regards to both the frequency domain and the reconstructed signal results.
7. For the decimated signal of Figure 5, does it appear that the decimation process has properly band-limited the signal prior to down-sampling? Has there been any loss of information? Discuss this in regards to both the frequency domain and the reconstructed signal results.
8. For the interpolated signal of Figure 6, does it appear that interpolation process has properly removed any problematic spectral harmonics from the signal after up-sampling? Has there been any loss of information? Discuss this in regards to both the frequency domain and the reconstructed signal results.
9. For the rate-changed signal of Figure 7, does it appear that the interpolation process has properly prevented aliasing and removed any problematic spectral harmonics from the signal after the rate-change? Has there been any loss of information? Does it appear that the signal has been properly resampled at the fractional 2/3rds rate? Discuss this in regards to both the frequency domain and the reconstructed signal results.

Assignment status: Solved by our experts

>>>Click here to get this paper written at the best price. 100% Custom, 0% plagiarism.<<<  Posted on