Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Sampling of a Sinusoidal Signal - Laboratory Exercise 5 Solutions | ECE 5213, Assignments of Digital Signal Processing

Report 5 Material Type: Assignment; Professor: Havlicek; Class: Digital Signal Processing; Subject: ELECTRICAL AND COMPUTER ENGINEERING; University: University of Oklahoma; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 08/31/2009

koofers-user-0wf
koofers-user-0wf 🇺🇸

0

(1)

10 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Name: SOLUTION (Havlicek)
Section:
Laboratory Exercise 5
DIGITAL PROCESSING OF CONTINUOUS-TIME SIGNALS
5.1 THE SAMPLING PROCESS IN THE TIME-DOMAIN
Project 5.1 Sampling of a Sinusoidal Signal
A copy of Program P5_1 is given below:
% Program P5_1
% Illustration of the Sampling Process
% in the Time-Domain
clf;
t = 0:0.0005:1;
f = 13;
xa = cos(2*pi*f*t);
subplot(2,1,1)
plot(t,xa);grid
xlabel('Time, msec');ylabel('Amplitude');
title('Continuous-time signal x_{a}(t)');
axis([0 1 -1.2 1.2])
subplot(2,1,2);
T = 0.1;
n = 0:T:1;
xs = cos(2*pi*f*n);
k = 0:length(n)-1;
stem(k,xs);grid;
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal x[n]');
axis([0 (length(n)-1) -1.2 1.2])
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download Sampling of a Sinusoidal Signal - Laboratory Exercise 5 Solutions | ECE 5213 and more Assignments Digital Signal Processing in PDF only on Docsity!

Name Section: SOLUTION (Havlicek):

DIGITAL PROCESSING OF CONTINUOUS-TIME SIGNALSLaboratory Exercise 5

5.1Project 5.1 THE SAMPLING PROCESS IN THE TIME-DOMAIN A copy of Program P5_1 is given below Sampling of a Sinusoidal Signal :

% Program P5_1% Illustration of the Sampling Process% in the Time-Domainclf;t = 0:0.0005:1;

f = 13;xa = cos(2pif*t);subplot(2,1,1)plot(t,xa);gridxlabel('Time, msec');ylabel('Amplitude');

title('Continuous-time signal x_{a}(t)');axis([0 1 -1.2 1.2])subplot(2,1,2);T = 0.1;n = 0:T:1;

xs = cos(2pif*n);k = 0:length(n)-1;stem(k,xs);grid;xlabel('Time index n');ylabel('Amplitude');title('Discrete-time signal x[n]');

axis([0 (length(n)-1) -1.2 1.2])

Answers: Q5.1 The plots of the continuous-time signal and its sampled version generated by running ProgramP5_1 are shown below:

-0.5-1^00 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

0.5^1

Amplitude Time, msec

Continuous-time signal x (^) a(t)

-0.5-1^00 1 2 3 4 5 6 7 8 9

0.5^1

Amplitude Time index n

Discrete-time signal x[n]

Q5.2 The frequency of the sinusoidal signal in Hz isshown in the upper graph is inmsec, or 13,000 cycles in one sec. msec. Thus, the sinusoid goes through 13 cycles in 1 – f = 13 kHz. This is because the time scale Q5.3^ The sampling period in seconds isThe effects of the twoand maximum values for the x-axis and the y-axis in the upper plot. The second axis commands are^ - T = 0.1 msec. – The first axis command sets the minimum axis command does the same thing for the lower plot. In eachparameters are the minimum and maximum values for the x-axis. The third and fourthparameters are the minimum and maximum values for the y-axis. axis command, the first two Q5.4 The plots of the continuous-time signal and its sampled version generated by running ProgramP5_1 for the following four values of the sampling period are shown below:

T = 0.15 msec

-0.5-1^00 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

0.5^1

Amplitude Time, msec

Continuous-time signal x (^) a(t)

-0.5-1^00 1 2 3 4 5

0.5^1

Amplitude Time index n

Discrete-time signal x[n]

T = 0.2 msec

-0.5-1^00 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

0.5^1

Amplitude Time, msec

Continuous-time signal x (^) a(t)

-0.5-1^00 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

0.5^1

Amplitude Time index n

Discrete-time signal x[n]

Based on these results we make the following observationsgoes through 13 cycles in the 1 msec shown in the graph, there will be aliasing unlesswe get at least two samples per cycle, or 26 samples total on the graph. 26 samples in 1msec is a sampling rate of 26 kHz, which requires T < 1/26 – Since the “analog” waveform ≈ 0.0385 msec to avoid aliasing.an appearance that is very similar to that of the “analog” waveform.msec, there is still no aliasing, but the sampling rate is much closer to being “critical,”i.e., much closer to the Nyquist rate. Consequently, the appearance of the discrete-time With T=0.004 msec. there is no aliasing and the discrete-time waveform has With T=0. waveform is less similar to the “analog waveform,” although perfect reconstruction isstill possible.waveform has the appearance of an “analog” waveform of much lower frequency.Finally, with T=0.2 msec, there is again severe aliasing which causes the discrete-time With T=0.15 msec, there is significant aliasing and the discrete-time Q5.5 waveform to have the appearance of an “analog” waveform of lower frequency.The plots of the continuous-time sinusoidal signal of frequency 3 kHz and its sampled versiongenerated by running a modified Program P5_1 are shown below error about the frequency. Since the “t” in the program is in units of msec, the : (NOTE: the book is in frequency here is 3 kHz, not 3 Hz.) -0.5-1^00 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

0.5^1

Amplitude Time, msec

Continuous-time signal x (^) a(t)

-0.5-1^00 1 2 3 4 5 6 7 8 9

0.5^1

Amplitude Time index n

Discrete-time signal x[n]

Project 5.2 % Program P5_2 A copy of Program P5_2 is given below Aliasing Effect in the Time-Domain :

% Illustration of Aliasing Effect in the Time-Domain% Program adapted from [Kra94] with permission from% The Mathworks, Inc., Natick, MA.clf;T = 0.1;f = 13;

n = (0:T:1)';xs = cos(2pifn);t = linspace(-0.5,1.5,500)';ya = sinc((1/T)t(:,ones(size(n))) - (1/T)n(:,ones(size(t)))')xs;plot(n,xs,'o',t,ya);grid;

xlabel('Time, msec');ylabel('Amplitude');title('Reconstructed continuous-time signal y_{a}(t)');axis([0 Answers: 1 -1.2 1.2]);

Q5.6 The plots of the discrete-time signal and its continuous-time equivalent obtained by runningProgram P5_2 are shown below:

0.60.8^1

Time, msec

Amplitude

Reconstructed continuous-time signal y (^) a(t)

Q5.7 The range of The value of the time increment is The range of tt in the Program isin the plot is - 0.0 - (^) ≤– 0.004− t 0.5 (^) ≤1.0 ≤ t ≤1.

The plot generated by running Program P5_2 again with the range ofdisplay the full range of ya(t) is shown below: t changed so as to

0.60.8^1

Time, msec

Amplitude

Reconstructed continuous-time signal y (^) a(t)

ya = sinc((1/T)t(:,ones(size(n))) - (1/T)n(:,ones(size(t)))')*xs;^ Based on these results we make the following observationson, the important line of the program is line 10, which reads:^ – To understand what is going Herevector “n.” n(:,ones(size(t)))'“t.” Each one of these rows contains a copy of the vector “n”. It is important to realize, t(:,ones(size(n))) Each column contains a copy of the entire vector “t.” is a matrix that has one row for each each entry in the vector is a matrix. It has one column for each element of the Similarly, that the vector “n” does not actually contain integers as you might expect.actually contains are the values nT, i.e., it contains integer multiples of the samplinginterval. What it So the quantityone row for each element of the vector “t” and one column for each element of thevector “n.” The argument of “ t(:,ones(size(n)))sinc” in line 10 of the program is this matrix times 1/T. - n(:,ones(size(t)))' is a matrix that has That is a matrix where the first row is exactly the values (t-nT)/T shown on page 73 ofthe Lab Manual in the sum of Eq. (5.14) when t is the first entry in the vector “t” and nranges not from −∞ to ∞ , but rather over all the values in the vector “n.” Likewise, the second row of this matrix is exactly the values (t-nT)/T from Eq. (5.14)when t is the second entry of the vector “t” and the third row of this matrix is the values(t-nT) in (5.14) when t is the third entry of the vector “t.”

The plots of the discrete-time signal and its continuous-time equivalent obtained by runningProgram P5_2 with the original display range restored and with the frequency of the sinusoidalsignal changed to 7 kHz are shown below here is 7 kHz, not 7 Hz.) : (Again the book is in error. The frequency is

0.60.8^1

Time, msec

Amplitude

Reconstructed continuous-time signal y (^) a(t)

Based on these results we make the following observationsis fairly severe aliasing; the reconstructed analog waveform is not of the samefrequency as the original analog waveform that was sampled. With f = 3 kHz in Q5.8,there is no aliasing. The reconstructed analog waveform exactly matches the original – With f = 13 kHz in Q5.6, there analog waveform that was sampled.not as severe as what we saw in Q5.6. These results can be explained as follows With f = 7 kHz in Q5.8, there is aliasing but it is – In all three cases, the sampling interval is T = 0.1 msec.interval would have to be shorter than 1/26that’s not the case (we have T = 0.1 msec), aliasing occurs.sinusoid of frequency f = 3 kHz, the sampling interval would have to be shorter than For an original analog sinusoid of frequency f = 13 kHz, the sampling ≈ 0.0385 msec to avoid aliasing. For an original analog Since 1/6msec), aliasing does not occur. Finally, for an original analog sinusoid of frequency f =7 kHz, the sampling interval would have to be shorter than 1/14avoid aliasing. Since that’s not the case here (we have T=0.1 msec), aliasing occurs. ≈ 0.1667 msec to avoid aliasing. Since that is the case here (we have T = 0.1 ≈ 0.0714 msec to

5.2 EFFECT OF SAMPLING IN THE FREQUENCY-DOMAIN A copy of Program P5_3 is given below Project 5.3 Aliasing Effect in the Frequency-Domain :

% Program P5_3% Illustration of the Aliasing Effect% in the Frequency-Domainclf;t = 0:0.005:10;

xa = 2t.exp(-t);subplot(2,2,1)plot(t,xa);gridxlabel('Time, msec');ylabel('Amplitude');title('Continuous-time signal x_{a}(t)');

subplot(2,2,2)wa = 0:10/511:10;ha = freqs(2,[1 2 1],wa);plot(wa/(2*pi),abs(ha));grid;xlabel('Frequency, kHz');ylabel('Amplitude');

title('|X_{a}(j\Omega)|');axis([0 5/pi 0 2]);subplot(2,2,3)T = 1;n = 0:T:10;

xs = 2n.exp(-n);k = 0:length(n)-1;stem(k,xs);grid;xlabel('Time index n');ylabel('Amplitude');title('Discrete-time signal x[n]');

subplot(2,2,4)wd = 0:pi/255:pi;hd = freqz(xs,1,wd);plot(wd/(Tpi), Tabs(hd));grid;xlabel('Frequency, kHz');ylabel('Amplitude');

title('|X(e^{j\omega})|');axis([0 1/T 0 2]) Answers:

Q5.9 The continuous-time function The CTFT ofmanually using a table to obtain xa(t) is being computed by x (^) a(t) in Program P5_3 is – The Laplace transform was computed - xa ( ) t = 2 te u tt ( ). The coefficient vectors [2] and [1 2 1] where then used as arguments to to obtain complex-valued samples of the frequency response X^ a ( ) s^^ =^ (1^ +^2 s^ )^^2 = s^^2 +^22 s +^1. X (^) a ( ω) at the freqs frequencies given in the vector wa.

Amplitude Time, msec

Continuous-time signal x (^) a(t) 0.5 (^010) 0.5 1 1.

1.5^2

Amplitude Frequency, kHz

|Xa(jΩ)|

Amplitude Time index n

Discrete-time signal x[n] 0.5 (^010) 0.2 0.4 0.

1.5^2

Amplitude Frequency, kHz

|X(ejω)| Based on these results we make the following observationsfrequency, the aliasing is now much more severe.even higher than it was before. The tail of | – with the reduction in sampling X e ( j ω (^) ) | is now raised Q5.12 The modified Program P5_3 for the case of the CTFT was determined as follows. By applying the time scaling property tothe Fourier transform pair e − 12 t (^2) ←⎯F (^) → 2 xπa e (t) − (^12) ω (^2) with a scale factor= e–^ πt^2 is given below a =: 2 , Note: π we obtain X (^) a ( ω =) (^) ( 2 π)− (^12) e − 8 ωπ (^22). Sincecalculate the CTFT spectrum directly. X (^) a ( ω (^) ) this= X (^) a function( ω). Thus, it is straightforward to include a code in the program to is real and non-negative, we have moreover that

% Program Q5_12A% Illustration of the Aliasing Effect% in the Frequency-Domainclf;t = 0:0.005:10;

xa = exp(-pi*(t.^2));subplot(2,2,1)plot(t,xa);gridxlabel('Time, msec');ylabel('Amplitude');title('Continuous-time signal x_{a}(t)');

subplot(2,2,2)wa = 0:10/511:10;ha = exp(-(wa.^2)/(8pi^2))/sqrt(2pi);plot(wa/(2*pi),abs(ha));grid;xlabel('Frequency, kHz');ylabel('Amplitude');

title('|X_{a}(j\Omega)|');axis([0 5/pi 0 1.5]);subplot(2,2,3)T = 1;n = 0:T:10;

xs = exp(-pi*(n.^2));k = 0:length(n)-1;stem(k,xs);grid;xlabel('Time index n');ylabel('Amplitude');title('Discrete-time signal x[n]');

subplot(2,2,4)wd = 0:pi/255:pi;hd = freqz(xs,1,wd);plot(wd/(Tpi), Tabs(hd));grid;xlabel('Frequency, kHz');ylabel('Amplitude');

title('|X(e^{j\omega})|');axis([0 1/T 0 1.5])

Amplitude Time, msec

Continuous-time signal x (^) a(t) 0.5 (^00) 0.5 1 1.

Amplitude Frequency, kHz

|Xa(jΩ)|

Amplitude Time index n

Discrete-time signal x[n] 0.5 (^00) 0.2 0.4 0.

Amplitude Frequency, kHz

|X(ejω)| Based on these results we make the following observationssignificantly decreased in this case, the aliasing is now severe. The sampled waveformthe magnitude spectrum | x [ ] n has the appearance of a Kronecker delta (discrete-time unit impulse). As a result, X e ( j ω (^) ) |is practically flat. – with the sampling rate 5.3Project 5.4 DESIGN OF ANALOG LOWPASS FILTERS A copy of Program P5_4 is given below Design of Analog Lowpass Filters :

% Program P5_4% Design of Analog Lowpass Filterclf;Fp = 3500;Fs = 4500;Wp = 2piFp; Ws = 2piFs;

[N, Wn] = buttord(Wp, Ws, 0.5, 30,'s');[b,a] = butter(N, Wn, 's');wa = 0:(3Ws)/511:3Ws;h = freqs(b,a,wa);plot(wa/(2pi), 20log10(abs(h)));grid

xlabel('Frequency, Hz');ylabel('Gain, dB');title('Gain response');axis([0 3*Fs -60 5]);

Answers:Q5.13 The passband ripple R (^) p in dB is – 0.5 dB The minimum stopband attenuation R The passband edge frequency in Hz is (^) s in dB is– 3.5 kHz - 30 dB Q5.14^ The stopband edge frequency in Hz isThe gain response obtained by running Program P5_4 is shown below^ – 4.5 kHz :

Frequency, Hz

Gain, dB

Gain response

Based on this plot we conclude that the filter designed The filter order N is The 3-dB cutoff frequency in Hz of the filter is - 18 – Wn = 3.7144 kHz MEETS_ the given specifications.

Q5.16 % Program Q5_16% Design of Analog Lowpass Filter The required modifications to Program P5_4 to design a Type 2 Chebyshev lowpass filtermeeting the same specifications are given below:

clf;Fp = 3500;Fs = 4500;Wp = 2piFp; Ws = 2piFs;[N, Wn] = cheb2ord(Wp, Ws, 0.5, 30,'s');[b,a] = cheby2(N, 30, Wn, 's');

wa = 0:(3Ws)/511:3Ws;h = freqs(b,a,wa);plot(wa/(2pi), 20log10(abs(h)));gridxlabel('Frequency, Hz');ylabel('Gain, dB');title('Gain response');

axis([0 3*Fs -60 5]);NWn The gain response obtained by running the modified Program P5_4 is shown below:

Frequency, Hz

Gain, dB

Gain response

Based on this plot we conclude that the filter designed The filter order N is The stopband edge frequency in Hz of the filter is -8 – 4.2653 kHz MEETS_ the given specifications.

Q5.17 % Program Q5_17% Design of Analog Lowpass Filter The required modifications to Program P5_4 to design an elliptic lowpass filter meeting thesame specifications are given below:

clf;Fp = 3500;Fs = 4500;Wp = 2piFp; Ws = 2piFs;[N, Wn] = ellipord(Wp, Ws, 0.5, 30,'s');[b,a] = ellip(N, 0.5, 30, Wn, 's');

wa = 0:(3Ws)/511:3Ws;h = freqs(b,a,wa);plot(wa/(2pi), 20log10(abs(h)));gridxlabel('Frequency, Hz');ylabel('Gain, dB');title('Gain response');

axis([0 3Fs -60 5]);NWn/(2pi) The gain response obtained by running the modified Program P5_4 is shown below:

Frequency, Hz

Gain, dB

Gain response

Based on this plot we conclude that the filter designed The filter order N is The passband edge frequency in Hz of the filter is - 5 – Wn = 3.5 kHz MEETS_ the given specifications.