0% found this document useful (0 votes)
74 views11 pages

DSP Lab 03

This document discusses aliasing effect in time and frequency domains. It presents: 1) Continuous and discrete time sinc functions. 2) Aliasing in time domain when sampling rate is too low, shown by non-matching reconstructed and original signals. 3) Aliasing disappears in time domain when sampling rate satisfies Nyquist criterion. 4) Aliasing in frequency domain when sampling a non-bandlimited signal, shown by spectra mismatch above Nyquist rate. 5) A Simulink model demonstrating aliasing of two signals with frequencies below and above sampling rate.

Uploaded by

affan haq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views11 pages

DSP Lab 03

This document discusses aliasing effect in time and frequency domains. It presents: 1) Continuous and discrete time sinc functions. 2) Aliasing in time domain when sampling rate is too low, shown by non-matching reconstructed and original signals. 3) Aliasing disappears in time domain when sampling rate satisfies Nyquist criterion. 4) Aliasing in frequency domain when sampling a non-bandlimited signal, shown by spectra mismatch above Nyquist rate. 5) A Simulink model demonstrating aliasing of two signals with frequencies below and above sampling rate.

Uploaded by

affan haq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

M.

Umer Ahsan LAB # 03 CE-118-2020

LAB # 03
ALIASING EFFECT IN TIME AND FREQUENCY DOMAIN
OBJECT:
 Aliasing Effect in Time and Frequency Domain
 Continuous Time and Discrete Time functions using sinc
 Aliasing Effect in the Time Domain
 Aliasing Effect in the Frequency-Domain
 Practice Aliasing Using Simulink

Sketching Continuous Time and Discrete Time functions

sinccomputes the sinc function of an input vector or array, where the sinc function is:

{
1, t=0
sinc ( t )= sinc (πt)
t≠0
πt
t=linspace(-5,5,50); % generates lineraly spaced vectors. It gives direct control over the number of
points.
y=sinc(t); %returns an array y the same size as x, whose elements are the sinc function of the element of
x.
subplot(2,1,1)
plot(t,y)
subplot(2,1,2)
stem(t,y);
xlabel('Time (sec)');
ylabel('Amplitude');
title('Since Function')

CE-320L: Digital System Processing Page 1 SSUET/QR/114


M.Umer Ahsan LAB # 03 CE-118-2020

Section A

Aliasing Effect in the Time Domain

With Aliasing

clf;
f=13;%frequency of sinusoid=13 Hz
T = 1/(13*1.5); %Sampling rate (1/T) is not following Nyquist sampling theorem
n = (0:T:1)';
xs = cos(2*pi*f*n);
t = [-0.5:0.004:1.5]';
ya = sinc((1/T)*t(:,ones(size(n))) - (1/T)*n(:,ones(size(t)))')*xs;
%This is Reconstruction lowpassfiltering,implemented in time-domain
subplot(2,1,1)
plot(n,xs,'o',t,ya);grid;%Reconstructed CT signal
xlabel('Time, sec');ylabel('Amplitude');
title('Reconstructed continuous-time signal y_{a}(t)');
axis([0 1 -1.2 1.2]);
subplot(2,1,2)
t=0:0.0005:1;
xa=cos(2*pi*f*t); %original CT Signal
plot(t,xa);grid;
xlabel('Time,sec');
ylabel('Amplitude');
title('Orignal Continuous-time signal x_{a}(t)');
axis([0 1 -1.2 1.2]);
%Note: Both Time-domain plots are not same, because of Aliasing.

CE-320L: Digital System Processing Page 2 SSUET/QR/114


M.Umer Ahsan LAB # 03 CE-118-2020

Without Aliasing
clf;
f=13;%frequency of sinusoid=13 Hz
T = 1/(13*2); %Sampling rate (1/T) is following Nyquist sampling theorem
n = (0:T:1)';
xs = cos(2*pi*f*n); %cos(w0 k) where k is integer and w0 =2*pi*f*T=2.6*pi
t = [-0.5:0.004:1.5]';
ya = sinc((1/T)*t(:,ones(size(n))) - (1/T)*n(:,ones(size(t)))')*xs;
%This is Reconstruction lowpassfiltering,implemented in time-domain
subplot(2,1,1)
plot(n,xs,'o',t,ya);grid;%Reconstructed CT signal
xlabel('Time, sec');ylabel('Amplitude');
title('Reconstructed continuous-time signal y_{a}(t)');
axis([0 1 -1.2 1.2]);

subplot(2,1,2)
t=0:0.0005:1;
xa=cos(2*pi*f*t); %original CT Signal
plot(t,xa);grid;
xlabel('Time,sec');
ylabel('Amplitude');
title('Orignal Continuous-time signal x_{a}(t)');
axis([0 1 -1.2 1.2]);

%Note: Both Time-domain plots are same, there is no of Aliasing.

Section B
CE-320L: Digital System Processing Page 3 SSUET/QR/114
M.Umer Ahsan LAB # 03 CE-118-2020

Aliasing Effect in the Frequency-Domain


Sampling a Non-band limited signal
t=0:0.006:10;
xa=2*t.*exp(-t);
figure;
subplot(2,2,1)
plot(t,xa);grid
xlabel('Time sec');
ylabel('Amplitude');
title('Continuous-time signal x_{a} (t)');

subplot(2,2,2)
fa=0:0.001:10;
wa=2*pi*fa;
Xa=2./((1-wa.^2)+1i*2*wa); %Xa is freq. specturm (i.e CT Fourier Transform) of xa. It's a non-
bandlimited signal
plot(fa(1:1500), abs(Xa(1:1500))); grid
xlabel('Frequency, Hz');
ylabel('Amplitude');
title('Xa Frequency spectrum');

subplot(2,2,3)
T=0.5; %Sampling-Rate selected as 2 Hz
%Aliasing will always occur as this is non-bandlimited signal
n=0:T:10;
xs=2*n.*exp(-n); % Actually sampled xs=2*T*n.*exp(-T.*n)
k=0:length(n)-1;
stem(k,xs);
grid;
xlabel('Time index n');
ylabel('Amplitude');
title('Discrete-timrdignal x[n]');
subplot(2,2,4)
wd=0:pi/255:pi;
Xs=freqz(xs,1,wd); %Xs is Freq. spectrum (i,e. DT Fourier Transform) of xs
%CTFT of upto freq. 1 Hz(Nyquist frequency) has been captured by DTFT (and
%the rest discraded), because sampling-rate is 2 Hz.
plot(wd/(2*T*pi),T*abs(Xs));
grid;
xlabel('Frequency Hz');
ylabel('Amplitude');
title('Xs Frequency spectrum');

CE-320L: Digital System Processing Page 4 SSUET/QR/114


M.Umer Ahsan LAB # 03 CE-118-2020

Section C
Assignment Task
Aliasing Using Simulink
Now to observe the effects of aliasing.

1. Create this Model in Simulink

2. Now insert the following setting in “Sine wave” block.

CE-320L: Digital System Processing Page 5 SSUET/QR/114


M.Umer Ahsan LAB # 03 CE-118-2020

3. Now insert the following setting in “Sine wave1” block.

4: Now change the axis of scope to 2 and check the results.

Explanation: Two continuous signals having two frequencies, one is 40 Hz and other 140
Hz. Both sampled at 100 samples/sec. but the plots of both signals are same. It means that
40 Hz and 140 Hz are alias frequencies when sampled at 100 samples/sec

CE-320L: Digital System Processing Page 6 SSUET/QR/114


M.Umer Ahsan LAB # 03 CE-118-2020

HOME TASK:

TASK # 01: Write a script to construct a continuous time sinusoid signal with amplitude=2 for
a time t and take the frequency as a user input by using input command.

Coding:

Result:

CE-320L: Digital System Processing Page 7 SSUET/QR/114


M.Umer Ahsan LAB # 03 CE-118-2020

TASK # 02: Write a script to construct continuous time signal of task #1 to a discrete time
signal and take the analog frequency as input. Sampling frequency should be less than twice of
analog signal frequency in Hertz.

Coding:

Result:

CE-320L: Digital System Processing Page 8 SSUET/QR/114


M.Umer Ahsan LAB # 03 CE-118-2020

TASK # 03: Write a script to construct continuous time signal of task#1 to a discrete time
signal and take the analog frequency as input. Sampling frequency should be equal to twice of
analog signal frequency in Hertz.
Coding:

Result:

CE-320L: Digital System Processing Page 9 SSUET/QR/114


M.Umer Ahsan LAB # 03 CE-118-2020

TASK # 04: Write a script to construct continuous time signal of task#1 to a discrete time
signal and take the analog frequency as input. Sampling frequency should be greater than twice
of analog signal frequency in Hertz.
Coding:

Result:

CE-320L: Digital System Processing Page 10 SSUET/QR/114


M.Umer Ahsan LAB # 03 CE-118-2020

TASK # 05: Write a script using subplot command to construct task #1, task#2, task#3 and
task#4 plots. Analyze the four plots, what happens by increasing the sampling frequency?
Coding:

Result:

CE-320L: Digital System Processing Page 11 SSUET/QR/114

You might also like