2002 Department of Electrical and Computer Engineering at Portland State
University. .... Singer, Computer Explorations in Signals and Systems using
MATLAB,.
Version 1.2
1 of 4
ECE 203 – LAB 4 SAMPLING BEFORE YOU BEGIN PREREQUISITE LABS • • •
ECE 201 Labs ECE 202 Labs ECE 203 MATLAB and LTI Systems
EXPECTED KNOWLEDGE • •
Understanding of LTI systems Basic understanding of Sampling principles.
EQUIPMENT •
Workstation with MATLAB 6
OBJECTIVES After completing this lab, you should have a better understanding of sampling theory and have a better understanding of aliasing.
INTRODUCTION The sampling theorem specifies conditions under which a bandlimited continuous-time signal can be completely represented by discrete samples. The resulting discrete-time signal x[n]=xc(nT) contains all the information in the continuous-time signal, so long as the continuoustime signal is sufficiently bandlimited in frequency. For example, X ( jω ) = 0 for | ω |≥ 22πT . When this condition is satisfied, the original continuous-time signal can be perfectly reconstructed by from x[n]. Discrete-time processing of continuous-time signals is often used in practice to take advantage of the digital integrated circuit technology. Figure 1 shows the architecture of this type of signal processing. xc(t)
C/D
T
Hd(ejω)
D/C
yc(t)
T
Figure 1: Discrete-time processing of a continuous-time signal.
© 2002 Department of Electrical and Computer Engineering at Portland State University.
Version 1.2
2 of 4
LAB ALIASING DUE TO UNDERSAMPLING Aliasing is an effect that is observed when a signal has frequency content that is greater than half the sampling frequency. This effect can commonly be seen in nature when the wheels of a car appear to be rotating slowly backwards when sampled with a movie camera, even though the car is moving forward. For this lab, we will look at the effects of aliasing of sinusoidal signals in the audio spectrum. This will be done both visually and audibly.
Basic Problems Consider the sinusoidal signal x(t ) = sin(ω0t ). If x(t) is sampled with frequency ωs=2π/T rad/sec, then the discrete-time signal x[n]=x(nT) is equal to x[n] = sin(ω0 nT ) . For the following problems, we will assume that ωs=2π(8192) rad/sec. Using MATLAB, set the following: ω0=2π(1000) rad/sec T=1/8192; n=[0:8191]; t=n*T; Create a vector x which contains the samples of x(t) at the time samples in t. Display the first fifty samples of x[n] versus n using stem. In the same figure, display the first fifty samples of x(t) versus t, using plot.
Answer question 1. Note that plot(t,x) displays a continuous-time signal given the samples in x, using strait lines to interpolate between sample values. While this interpolation is not generally equal to the bandlimited reconstruction which follows from the sampling theorem, it can often be a very good approximation. To compute samples of the estimated continuous-time Fourier transform, of the bandlimited reconstruction xr(t), use the function ctfts which is posted on the web site with this lab assignment. This function uses fft to estimate the Fourier transform of the reconstructed signal. Use [X,f]=ctfts(x,T) to calculate the continuous-time Fourier transform of the reconstructed signal xr(t). Plot the magnitude of X versus f. Note that X has imaginary values, therefore, the magnitude is going to be the absolute value of X.
Answer questions 2 – 3.
© 2002 Department of Electrical and Computer Engineering at Portland State University.
Version 1.2
3 of 4
Intermediate Problems We will examine the effects of aliasing by considering what happens as we increase the frequency of a pure sinusoidal tone. For each of the frequencies listed, create a plot of the estimate continuous-time Fourier transform using the ctfts function described above. Change ω0 to 2π(3000) rad/sec, 2π(4000) rad/sec, 2π(5000) rad/sec, and 2π(6000) rad/sec. Using the ctfts function, create plots of X vs f for each frequency.
Answer questions 4 – 8. Listen to each signal using soundsc(x,1/T).
Answer question 9. Note: like plot, the function soundsc performs interpolation. Your computer converts the discrete-time signal in MATLAB into a continuous-time signal using a digital-to-analog converter, and then plays this continuous-time signal through the speakers.
Advanced Problems For this section, we will experiment with a signal that changes frequency on it’s own. The general form of the signal is as follows:
x(t ) = sin ( (ω 0 + 12 β t ) t ) This signal is commonly known as a “chirp”, due to the increasing instantaneous frequency of the signal over time. The instantaneous frequency of a sinusoidal signal is given by the derivative of its phase, i.e., the argument of sine function. For the chirp signal, the instantaneous frequency is:
ωinst (t ) =
d ω 0t + 12 β t 2 = ω 0 + β t dt
(
)
For the following problems, we will assume that ωs =2π(8192) rad/sec. Set ω0 =2π(3000) rad/sec and β=2π(1000) rad/sec2. Store in the vector x the samples of the chirp signal on the interval 0 ≤ t ≤ 2. Make sure to use the array power operator for squaring t in the second term, not the standard power operator. Use soundsc to play the chirp signal contained in x.
Answer question 10. Store in x the samples for the first 12 seconds of the chirp signal, and play the signal using sound. You will need to change the t vector so that it extends to 12 seconds. Make sure to keep the number of samples per second the same.
© 2002 Department of Electrical and Computer Engineering at Portland State University.
Version 1.2
4 of 4
Answer questions 11 – 12.
REFERENCES [1] Buck, Daniel, Singer, Computer Explorations in Signals and Systems using MATLAB, Prentice Hall 2002, Chapter 7.
© 2002 Department of Electrical and Computer Engineering at Portland State University.