Professional Documents
Culture Documents
Netaji Subhas University of Technology New Delhi: Data Communication Practical File
Netaji Subhas University of Technology New Delhi: Data Communication Practical File
NEW DELHI
DATA COMMUNICATION
Practical File
Theory
The rectangular function (also known as the rectangle function, rect function, Pi
function, gate function, unit pulse, or the normalized boxcar function) is defined as
Code
clc;
clear all;
close all;
t1 = -10:0.1:10;
y = 5 * rectpuls(t1,10);
figure(1)
plot(t1,y)
figure(2)
z = fft(y);
plot(fftshift(abs(z)))
Graph
Experiment 2 ) To verify following properties of Fourier Transform:
i. Time Shifting,
ii. Frequency shifting,
iii. Convolutional
Theory
i) Time Shifting: The time shifting property of Fourier transform states that if a signal 𝑥(𝑥) is
shifted by 𝑥0 in the time domain, then the frequency spectrum is modified by a linear phase
shift of slope (−𝑥𝑥0). Therefore, if,
ii) Frequency Shifting: The linearity property of Fourier transform states that the Fourier
transform of a weighted sum of two signals is equal to the weighted sum of their individual
Fourier transforms. Therefore if,
iii) Convolution Shift: The convolution of two signals in time domain is equivalent to the
multiplication of their spectra in frequency domain. Therefore, if
a) Time shift
clc;
clear all;
close all;
N=20;
n=0:1:(N-1);
x=(0.8).^n;
subplot(2,1,1);
title('x(n)')
xlabel('n')
ylabel('x(n)')
stem(n,x);
m= -3;
x1=circshift(x,N);
n1=mod(n-m,N);
subplot(2,1,2);
stem(n1,x1);
b) Frequency shift
CODE :-
Theory
In probability theory and statistics, the exponential distribution is the probability distribution
of the time between events in a Poisson point process, i.e., a process in which events occur
continuously and independently at a constant average rate. It is a particular case of the
gamma distribution.
Here λ > 0 is the parameter of the distribution, often called the rate parameter. The distribution
is supported on the interval [0, ∞). If a random variable X has this distribution, we write X ~
Exp(λ).
The exponential distribution exhibits infinite divisibility.
Code
clear all
close all
clc
x = 0 : 0.1 : 100;
lambda = 0.5;
fx = lambda * exp(-lambda * x);
subplot(211);
plot(x, fx);
xlim([0 20]);
title("PDF of exponential distribution");
Fx = 1 - exp(-lambda * x);
subplot(212);
plot(x, Fx);
xlim([0 20]);
title("CDF of exponential distribution");
n = 10000;
R = rand(1, n);
U = (R - min(R)) / (max(R) - min(R)) + 0.001;
X = -1 / lambda * log(U);
fX = zeros(1, n);
bins = 10;
Min = min(X);
Max = max(X);
interval = (Max - Min) / bins;
for i = 1 : n
j = floor((X(i) - Min) / interval) + 1;
fX(j) = fX(j) + 1;
end
fX = fX / n;
figure(2)
subplot(311);
plot(0 : n - 1, fX);
xlim([0 10]);
title("PDF of inverse exponential transform of uniform R.V.");
FX = zeros(1, n + 1);
Sum = 0;
for i = 1 : n
Sum = Sum + fX(i);
FX(i + 1) = Sum;
end
subplot(312);
plot(0 : n, FX);
xlim([0 10]);
title("CDF of inverse exponential transform of uniform R.V.");
subplot(313);
plot(x, Fx);
xlim([0 10]);
title("CDF of exponential distribution");
Experiment4) Study of linear and non- linear quantization.
Theory
The analog-to-digital converters perform this type of function to create a series of digital
values out of the given analog signal. The following figure represents an analog signal. This
signal to get converted into digital, has to undergo sampling and quantizing.
The quantization of an analog signal is done by discretizing the signal with a number of
quantization levels. Quantization is representing the sampled values of the amplitude by a
finite set of levels, which means converting a continuous-amplitude sample into a discrete-
time signal.
The following figure shows how an analog signal is quantized. The blue line represents
analog signal while the brown one represents the quantized signal.
Qb = linearQuant(-0.4);
Qbm = linearQuantMid(-0.4);
function Q = linearQuant(x)
N = -4; % Number of bits of quantizer
L = 2^N; % Number of levels
Vmax = 5; % Max input
Vmin = -5; % Min input
delta = (Vmax - Vmin)/L;
for i = -L/2 + 1:1:L/2
if x < -L/2
Q = -L/2 + 1;
elseif x > L/2
Q = L/2;
elseif (i)*delta <= x && x < (i+1)*delta
Q = i;
end
end
end
function Q = linearQuantMid(x)
N = 3; % Number of bits of quantizer
L = 2^N; % Number of levels
Vmax = 5; % Max input
Vmin = -5; % Min input
delta = (Vmax - Vmin)/L;
for i = -L/2 + 1:1:L/2
if x <= -L/2 + delta
Q = -L/2 + 1;
elseif x > L/2 - delta
Q = L/2;
elseif (i - 0.5)*delta <= x && x < (i+0.5)*delta
Q = i;
end
end
End