Professional Documents
Culture Documents
Lab Report
By
Submitted
To
Lec. Rafi
Semester: 6th
Session: Spring 2021
Credit Hours: 1
Time: 3 Hours
2
National University of Technology
Experiment List
Sr.No. Experiments
3
National University of Technology
Experiment 4
Sampling and Aliasing using MATLAB
Objective
To investigate the sampling of continuous-time signals and the effects of aliasing. This lab covers
the implementation of sampling of a continuous time signal and to analyze the aliasing effect that
occurs due to improper sampling.
Theoretical Explanation
4
National University of Technology
Explanation of Procedure
A. Tools/Commands
1. MATLAB
B. Codes
1. Lab task 1
%TASK # 4.1
t=-0.5:0.0005:0.5;
fo1=3;fo2=7;fo3=13;
x1t=cos(2*pi*fo1*t);
x2t=cos(2*pi*fo2*t);
x3t=cos(2*pi*fo3*t);
fsa=10;fsb=13;fsc=26;fsd=52;fse=80;fsf=130;
%for x1
figure(1);
% For fsa
n=0:(0.5*fsa)-1;
xs1=cos(2*pi*fo1*n/fsa);
subplot(231)
stem(n,xs1)
% For fsb
n=0:(0.5*fsb)-1;
xs1=cos(2*pi*fo1*n/fsb);
subplot(232)
stem(n,xs1)
% For fsc
n=0:(0.5*fsc)-1;
xs1=cos(2*pi*fo1*n/fsc);
subplot(233)
stem(n,xs1)
% For fsd
n=0:(0.5*fsd)-1;
xs1=cos(2*pi*fo1*n/fsd);
subplot(234)
stem(n,xs1)
% For fse
5
National University of Technology
n=0:(0.5*fse)-1;
xs1=cos(2*pi*fo1*n/fse);
subplot(235)
stem(n,xs1)
% For fsf
n=0:(0.5*fsf)-1;
xs1=cos(2*pi*fo1*n/fsf);
subplot(236)
stem(n,xs1)
%for x2
figure(2);
% For fsa
n=0:(0.5*fsa)-1;
xs2=cos(2*pi*fo2*n/fsa);
subplot(231)
stem(n,xs2)
% For fsb
n=0:(0.5*fsb)-1;
xs2=cos(2*pi*fo2*n/fsb);
subplot(232)
stem(n,xs2)
% For fsc
n=0:(0.5*fsc)-1;
xs2=cos(2*pi*fo2*n/fsc);
subplot(233)
stem(n,xs2)
% For fsd
n=0:(0.5*fsd)-1;
xs2=cos(2*pi*fo2*n/fsd);
subplot(234)
stem(n,xs2)
% For fse
n=0:(0.5*fse)-1;
xs2=cos(2*pi*fo2*n/fse);
subplot(235)
stem(n,xs2)
% For fsf
n=0:(0.5*fsf)-1;
xs2=cos(2*pi*fo2*n/fsf);
subplot(236)
stem(n,xs2)
%for x3
figure(3);
% For fsa
n=0:(0.5*fsa)-1;
xs3=cos(2*pi*fo3*n/fsa);
subplot(231)
stem(n,xs3)
% For fsb
n=0:(0.5*fsb)-1;
xs3=cos(2*pi*fo3*n/fsb);
6
National University of Technology
subplot(232)
stem(n,xs3)
% For fsc
n=0:(0.5*fsc)-1;
xs3=cos(2*pi*fo3*n/fsc);
subplot(233)
stem(n,xs3)
% For fsd
n=0:(0.5*fsd)-1;
xs3=cos(2*pi*fo3*n/fsd);
subplot(234)
stem(n,xs3)
% For fse
n=0:(0.5*fse)-1;
xs3=cos(2*pi*fo3*n/fse);
subplot(235)
stem(n,xs3)
% For fsf
n=0:(0.5*fsf)-1;
xs3=cos(2*pi*fo3*n/fsf);
subplot(236)
stem(n,xs3)
7
National University of Technology
8
National University of Technology
2. Lab task 2
For x1: f1= 3Hz but and for Fs just for 10,13,26Hz (it has limit 30 we can’t exceed it ),so I also did for 30Hz.
9
National University of Technology
10
National University of Technology
11
National University of Technology
12
National University of Technology
13
National University of Technology
14
National University of Technology
15
National University of Technology
3. Lab task 3
p and q both have same values and my audio was at normal speed
16
National University of Technology
When my p=3 and q= 1 my audio becomes fast with respect to originals audio
When q=3 and p=1 my audio becomes slow that a 6 sec audio were playing in 15 sec
17
National University of Technology
Conclusion
The sample rate is how many samples, or measurements, of the sound are taken each second. The
more samples that are taken, the more detail about where the waves rise and fall is recorded and the
higher the quality of the audio. Also, the shape of the sound wave is captured more accurately.
When the sampling rate (Fs) is increased, the distance between the maximum frequency content
Fm and Fs/2 will increase. This increase in the gap between the maximum frequency content of the
signal and Fs/2 will ease requirements on the transition bands of the anti-aliasing analog filter.
18