0% found this document useful (0 votes)
86 views

DSP Lab # 8 Sampling in Time Domain: Questions

The document describes a digital signal processing lab experiment on sampling in the time domain. It contains code to sample a sinusoidal signal and reconstruct it using low-pass filtering. It asks questions about the effect of changing the signal frequency and sampling rate on the discrete-time signal and whether aliasing occurs.

Uploaded by

nouman
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

DSP Lab # 8 Sampling in Time Domain: Questions

The document describes a digital signal processing lab experiment on sampling in the time domain. It contains code to sample a sinusoidal signal and reconstruct it using low-pass filtering. It asks questions about the effect of changing the signal frequency and sampling rate on the discrete-time signal and whether aliasing occurs.

Uploaded by

nouman
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Digital Signal Processing Lab Electrical Engineering Department

DSP LAB # 8 Sampling in time domain


Following program demonstrates effect of sampling in time domain. A analog signal is
sampled and reconstructed using low pass filtering.

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])

Questions

Q1.1 What is the frequency in Hz of the sinusoidal signal? What is the sampling period in
seconds?
Q1.2 Repeat the program by changing the frequency of the sinusoidal signal to 3 Hz and
7 Hz, respectively. Is there any difference between the corresponding equivalent discrete-
time signals. If not, why not?

Aliasing Effect in the Time Domain


In this project you will generate a continuous-time equivalent y(t) of the discrete-time
signal x[n] to investigate the relation between the frequency of the sinusoidal signal x(t)
and the sampling period. To generate the reconstructed signal y(t) from x[n], we pass x[n]
through an ideal lowpass filter.

clear all;
N=5;
fo=3; % maximum frequency in the signal
fs=10; % Sampling frequency

% Analog signal
t=0:0.005:N;

1
Digital Signal Processing Lab Electrical Engineering Department

x_t=sin(2*pi*fo*t);
% Digital signal
n=0:1:N*fs;
x_n=sin(2*pi*fo*n/fs);

j=0;
%for k=0:1/fs:N
% code for sequence of delayed sinc pulses

for k=0:1:N*fs
j=j+1;
h(j,:)=sinc((t-k/fs)*fs); % Each column represents a delayed sinc
end

y=x_n*h;
plot(n/fs,x_n,'o',t,y);grid;
xlabel('Time, msec');ylabel('Amplitude');
title('Reconstructed continuous-time signal y_{a}(t)');
figure;
xlabel('Time, msec');ylabel('Amplitude');
title('continuous-time signal y_{a}(t) sampled');
plot(n/fs,x_n,'o',t,x_t)

Q1.3 Repeat above program by changing the frequency of the sinusoidal signal to 3 Hz
and 7 Hz, respectively. Is there any difference between the corresponding equivalent
discrete-time signals and the one generated in Question.

Effect of sampling in frequency domain

clf;
t = 0:0.005:10;
xa = 2*t.*exp(-t);
subplot(2,2,1)
plot(t,xa);grid
xlabel('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;

2
Digital Signal Processing Lab Electrical Engineering Department

n = 0:T:10;
xs = 2*n.*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/(T*pi), T*abs(hd));grid;
xlabel('Frequency, kHz');ylabel('Amplitude');
title('|X(e^{j\omega})|');
axis([0 1/T 0 2]);

Q1.4 Run Program above to generate and display both the discrete-time signal and its
continuous-time equivalent, and their respective Fourier transforms. Is there any visible
effect of aliasing?
Q1.5 Repeat above program by increasing the sampling period to 1.5. Is there any visible
effect of aliasing?
2
Q1.6 Modify Program above program for the case of x(t) = e−πt and repeat
Questions 1.4 and 1.5.

You might also like