0% found this document useful (0 votes)
10 views10 pages

Lab 3a

Uploaded by

noorelahibajwa2
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)
10 views10 pages

Lab 3a

Uploaded by

noorelahibajwa2
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/ 10

Digital Signal Processing [EL- 3121.

Laboratory Exercise 3a

ALIASING EFFECT IN ANALOG

SIGNALS

OBJECTIVE:

1. Plot two continuous-time signals of 10 Hz and 110 Hz.


2. Sample at Fs = 100 Hz.
3. Analyze the effect of aliasing by plotting both signals in discrete form.
4. Plot discrete-time signals with different frequencies and analyze the
similarities and differences.

EXERCISE:

Task #1: Plot two CT signals of 10 Hz and 110 Hz for 0 < t < 0.2 secs. Sample at
Fs = 100 Hz and plot them in discrete form.

Coding
: f1 =
10
f2 =110; fs = 100; t = 0:0.001:0.2; x1 =
sin(2*pi*f1*t); x2 = sin(2*pi*f2*t);
plot(t,x1,t,x2) n1 = 0: 1/fs: 2/f1; n2 = 0:1/fs:
11/f2; y1 = sin(2*pi*f1*n1); y2 =
sin(2*pi*f2*n2) subplot(3,1,2); stem(n1,y1);
subplot(3,1,3); stem(n2,y2);

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering
Digital Signal Processing [EL- 3121.]

Result:

Task #2(a) For a C.T signal x=sin(2πft)


Plot the signal x(n) for n=0 to 99 for f=[500 2000 3000 4500] sampled at
fs=5000hz.
● Plot the signal x(n).
● Plot the signal x(n) created by even number samples of x(n)

Coding:

n = 0:99; fs = 5000;
for i = 1:4 f = [500
2000 3000 4500 ]
x = sin(2*pi*f(i)*n/fs);
subplot(4,1,i) stem (n,x)
end

Result:

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering
Digital Signal Processing 2022F-BEL-027

Task #2(b)
Suppose that f=2khz & fs = 50khz
1. 1) plot the signal x(n)
2. 2)plot the signal x(n) created by even number samples of x(n)

Coding: n = 0:99; f
=2000 fs = 50000;
for i = 1:4 f = [500
2000 3000 4500 ]
x = sin(2*pi*f(i)*n/fs);
subplot(4,1,i) stem (n,x)
End

Result:

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering
Digital Signal Processing [EL- 3121.]

Conclusion:

In this lab, I observed the phenomenon of aliasing, which occurs when


continuous signals are sampled at rates below the Nyquist frequency. This
results in higher frequencies being incorrectly represented as lower ones.
By comparing discrete-time signals at various sampling rates, I learned the
crucial role of selecting an appropriate sampling rate to maintain signal
accuracy and avoid distortion.

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering
Digital Signal Processing 2022F-BEL-027

OBJECTIVE:
Simulate a discrete-time continuous sinusoid signal with length of the signal be 500.
Choose the significant digits for round-off and apply to the signal above.
Compute error signals and SQNR.
Now choose significant digits for truncation for the same signal given above.
Analyze the difference between round-off and truncation.

TASK#I: Differentiate between mind off and tnmcation and also use
MATLAB help to get familiar with the syntax of both method

In a computation, each number must be rounded to a certain number of


digits. On this fact, round- off error depends. It is caused by truncating a
mathematical procedure.
At the finite process replaces infinite one, truncation errors. Approximating
mathematical procedures cause this error. It has two types in case of numerical
integration, these are global and local truncation errors.

Round Off:
help round round rounds towards near—st
decimal or

round (X) rounds —ach element af X to the nearest integer .

round (X, N), far positive integers N, rounds to N digits to the right oof the decimal
point. If N is zero, X is round—cl to the nearest integer.
If N is less than X is rounded Of point.
N must be a scalar integer.

round (X, N, 'significant') rounds each Element to its N mast significant digits,
counting from the most—significant or Left side oof the nurrber . N must be a
positive integer scalar .

Tnmcate :
>> help fix fix Round towards
zero.
fix (X) rounds the elements of X to the nearest integers towards zero.

TASK#2: Simulate a discrete continuous valued (DTCV) sinusoid of 1/50


cycles/sample with length of the signal to be 500& choose the no. of

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering
Digital Signal Processing [EL- 3121.]

significant digits for round-off and apply to the signal generated above.
Compute the error signals and SQNR.

CODE:

N=søe•, n=Ø: 499; q=input( '


Enter the value to quantize:
x=sin(2*pi*f*n);

xe=x -xq ;
Px=(1/N)*sin(x.*x);
I/N ) *xe);
sqnr=1Ø*10g(Px/Pe)
OUTPUT:
Enter the value to

zee .2285
TASK#3: For F = 1/50 and length of the signal to be 200, wmite a program
to quantize the signal x (n), using Truncation. Also increase number of
levels by increasing amplitude of the signal. Plot the signals x (n), xq (n)
and eq (n) and also compute the corresponding SQNR.
CODE:

N=2øe•, n=Ø: 199; q=input( '


Enter the value to quantize:
x=sin(2*pi*f*n); subplot (3, 1, 1);
stem (n, x) ; xq=f x*1ØA q ) /1Ø
A
q ; subplot (3, 1, 2); stem (n, xq)
; xe=x -xq ; subplot (3, 1, 3);
stem (n, xe) ;
*xe
sqnr=1Ø*10g(Px/Pe)
Enter the to quantize :

stinr

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering
Digital Signal Processing 2022F-BEL-027

273.4899

200

200

1; IGwh•lb

o 20 40 60 80 100 120 140 160 IBO 200

TASK#4: Use round off method by using for loop and take significant digits
as input i.e. 1, 2 &3.In each case plot the signals x (n), xq (n) and eq (n)
and also compute the conæsponding
SQNR.
CODE:

N=2eø•, n=Ø: 199; q=input( '


Enter the value to quantize:
x=sin(2*pi*f*n); subplot (3, 1, 1);
stem (n, x) ;

subplot (3,
1, 2); stem
(n, xq) ;
xe=x -xq ;
subplot (3,
1, 3); stem
(n, xe) ;
Px=(1/N)*sin(x.*x);
I/N ) *xe);
sqnr=1Ø*10g(Px/Pe)

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering
Digital Signal Processing [EL- 3121.]

Entzr the value to waantizz: 3

148 . 9629

200

200
-4

-5 200

OUTPUT #2:
Enter the value to vaantize :

200

-5 200

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering
Digital Signal Processing [EL- 3121.]

OUTPUT:

200
# 3:

Enter the value to waantize :

sclnr —

426.1753

80 12 14 180 2
00

80 12 14 16 200
x10 10

-
80 200

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering
Digital Signal Processing [EL- 3121.]

CONCLUSION:

In this lab we designed a specialized input program that employs the


Truncation method to determine the quantization length from discrete-
time, continuous-valued (DTCV) signals. This approach improves the
precision of signal processing, ensuring more consistent and dependable
results

Sir Syed University of Engineering & Technology, Karachi Department


of Electrical Engineering

You might also like