0% found this document useful (0 votes)
149 views8 pages

Lab Report 6: Digital System and Processing

The document is a lab report that discusses digital signal processing concepts like sampling, aliasing, decimation, and interpolation. It includes 4 tasks: 1) sampling signals at different rates and analyzing aliasing, 2) same as 1), 3) sampling signals with different frequencies at rates that do and do not cause aliasing, 4) analyzing the FFT of a speech signal before and after decimation and interpolation. The conclusion summarizes that sampling converts continuous to discrete signals, the Nyquist criterion must be met to avoid aliasing, and decimation uses anti-alias filtering before downsampling to satisfy the criterion.

Uploaded by

areej
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)
149 views8 pages

Lab Report 6: Digital System and Processing

The document is a lab report that discusses digital signal processing concepts like sampling, aliasing, decimation, and interpolation. It includes 4 tasks: 1) sampling signals at different rates and analyzing aliasing, 2) same as 1), 3) sampling signals with different frequencies at rates that do and do not cause aliasing, 4) analyzing the FFT of a speech signal before and after decimation and interpolation. The conclusion summarizes that sampling converts continuous to discrete signals, the Nyquist criterion must be met to avoid aliasing, and decimation uses anti-alias filtering before downsampling to satisfy the criterion.

Uploaded by

areej
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/ 8

LAB REPORT 6

DIGITAL SYSTEM AND PROCESSING

ALI HAMZA
FA17-BEE-012
Lab # 06 Sampling and Multi-rate Signal Processing

Objective:
 Sampling
 Rates of sampling
 Upsamlping
 Downsampling
 Antiliasing

Pre-Lab Work:

Introduction: The signals we use in the real world, such as our voices, are called "analog"
signals. To process these signals in computers, we need to convert the signals to "digital" form.
While an analog signal is continuous in both time and amplitude, a digital signal is discrete in
both time and amplitude. To convert a signal from continuous time to discrete time, a process
called sampling is used. The value of the signal is measured at certain intervals in time. Each
measurement is referred to as a sample. (The analog signal is also quantized in amplitude, but
that process is ignored in this demonstration.

Lab Tasks

Task-1:
Use your ‘sin’ or ‘cos’ function to generate a sinusoid wave having two components as f1 =
3kHz and f2 = 5kHz and then sample it with fs = 10kHz. Calculate its fft with zero
frequency component in the middle. Plot it on a properly scaled w-axis. Specify if there is
aliasing or not? If there is aliasing specify which component is casing the aliasing.
n = -50:50;

f1 = 3000;

f2=5000;

fs =10000;

x = sin(2*pi*(f/fs)*n);

L = length(x);

NFFT = 2^nextpow2(L);

y = fft(x,NFFT);

w1 = fs/2*linspace(0,1,NFFT/2+1);

w2= fs/2*linspace(-1,0,NFFT/2-1);

w = [w1 w2];

stem(w,2*abs(y))

Task-2:
Use your ‘sin’ or ‘cos’ function to generate a sinusoid wave having two components as f1 =
3kHz and f2 = 5kHz and then sample it with fs = 8kHz. Calculate its fft with zero frequency
component in the middle. Plot it on a properly scaled w-axis. Specify if there is aliasing or
not? If there is aliasing specify which component is casing the aliasing.

n = -50:50;

f1 = 3000;

f2=5000;

fs = 8000;

x = sin(2*pi*(f/fs)*n)

%subplot(2,1,1)

%stem(n,x);

L = length(x);

NFFT = 2^nextpow2(L);

y = fft(x,NFFT);

w1 = fs/2*linspace(0,1,NFFT/2+1);

w2= fs/2*linspace(-1,0,NFFT/2-1);
w = [w1 w2];

%subplot(2,1,2)

stem(w,2*abs(y))

xlabel('Hz');

ylabel('Amplitude');

There is aliasing as our maximum frequency is 5000 and we are not getting impulse on it so there
is a loss of information as fs=8000 which doesn’t satisfies the Nyquist criteria.

Task-3:
Use your ‘sin’ or ‘cos’ function to generate a sinusoid wave having two components as f1 =
1.5kHz and f2 = 4kHz and f3 = 7kHz and then (a) sample it with an fs such that there is no
aliasing (b) sample it with an fs which produces aliasing. Show the result in both cases by
plotting fft of the discretized signal.

Lets say firstly we take fs=12000 in this case aliasing will occur some of information will lose
and then we take fs=16000 so no aliasing as maximum frequency is 7000
n = -50:50; n = -50:50;

f1 = 1500; f1 = 1500;

f2=4000; f2=4000;

f3=7000; f3=7000;

fs=12000; fs=16000;

x = sin(2*pi*(f1/fs)*n)+sin(2*pi*(f2/fs)*n) x = sin(2*pi*(f1/fs)*n)+sin(2*pi*(f2/fs)*n)
+sin(2*pi*(f3/fs)*n); +sin(2*pi*(f3/fs)*n);

L = length(x); L = length(x);

NFFT = 2^nextpow2(L); NFFT = 2^nextpow2(L);

y = fft(x,NFFT); y = fft(x,NFFT);

w1 = fs/2*linspace(0,1,NFFT/2+1); w1 = fs/2*linspace(0,1,NFFT/2+1);

w2= fs/2*linspace(-1,0,NFFT/2-1); w2= fs/2*linspace(-1,0,NFFT/2-1);

w = [w1 w2]; w = [w1 w2];

stem(w,2*abs(y)) stem(w,2*abs(y))
Task-4:
Take a speech signal
Plot fft of the signal
Downsample (decimate) the signal in part-(ii) by 2 and plot its fft. Comment if there is aliasing or
not?
Now upsample (interpolate) the signal in part-(ii) by 2 and plot its fft. Comment on the outcome?
Compare the fft of in part-(i) and in part-(iii) and comment on whether or not the interpolation
operation recovers the information lost during decimation operation?

recObj = audiorecorder(44100, 16, 2);

fs=44100;

get(recObj) ;

recObj = audiorecorder;

disp('Start speaking.')

recordblocking(recObj,7);

disp('End of Recording.');

myRecording = getaudiodata(recObj);

x=myRecording; %plot waveforms

subplot(4,1,1)

stem(myRecording);
sound(myRecording);

L = length(x);

NFFT = 2^nextpow2(L);

y = fft(x,NFFT);

f_ax1 = fs/2*linspace(0,1,NFFT/2+1);

f_ax2 = fs/2*linspace(-1,0,NFFT/2-1);

f_ax = [f_ax1 f_ax2];

subplot(4,1,2)

stem(f_ax,2*abs(y));

x1 = decimate(x,2);

L = length(x1);

NFFT = 2^nextpow2(L);

y = fft(x1,NFFT);

f_ax1 = fs/2*linspace(0,1,NFFT/2+1);

f_ax2 = fs/2*linspace(-1,0,NFFT/2-1);

f_ax = [f_ax1 f_ax2];

subplot(4,1,3)

stem(f_ax,2*abs(y));

sound(x1)

x2=interp(x1,2);

L = length(x2);

NFFT = 2^nextpow2(L);

y = fft(x2,NFFT);

f_ax1 = fs/2*linspace(0,1,NFFT/2+1);

f_ax2 = fs/2*linspace(-1,0,NFFT/2-1);

f_ax = [f_ax1 f_ax2];

subplot(4,1,4)

stem(f_ax,2*abs(y));

sound(x2)
Output:

Conclusion:
The main objective of this lab was to learn about:

Sampling:
It is a process of converting a continuous signal into a discrete signal. Physical meaning of
sampling is “to measure and store/save a continuous quantity after a particular interval of
time”.To avoid any loss of information and fully reconstruct the continuous signal back from the
discrete signal, there is a limit to which we can increase the sampling time Ts or decrease the
sampling rate (fs= 1/Ts ). This limit is defined by the Nyquist criteria

Nyquist Criterion:
Itstates that for the digital signal to be correctly reconstructed it must be sampled at twice the
frequency of the maximum frequency signal in the original analog signal.Fs >2fmax When the
continuous function being sampled contains no frequencies equal or higher than thehalf of the
sampling rate, there is no loss of the information i.e. Nyquist criteria is fulfilled. Butif the
continuous signal contains a frequency component higher than half the sampling rate
thenaliasing occurs and exact reconstruction is not possible.

Aliasing:
It is caused by the repetition of X(jω) on the multiples of ωs i.e. X(jω-k ωs) if ωs < 2ωM. It
means that the repeated spectrums overlap with each in frequency domain hence making it
impossible to recover the complete information i.e. some information is lost forever.In simpler
wordif there is loss of information i.e FS is higher or equal then aliasing do not occurs and vice
versa.
Decimation:
The process that ensures that the sampling theorem is satisfied, alow-pass filter is used as an
anti-aliasing filter to reduce the bandwidth of the signal before the signal is down sampled.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy