Netaji Subhas University of Technology New Delhi: Data Communication Practical File

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

NETAJI SUBHAS UNIVERSITY OF TECHNOLOGY

NEW DELHI

DATA COMMUNICATION
Practical File

NAME: Devesh K. Sharma


ROLL NO: 2021UCS1583
INDEX

Expt No. Experiment Signature

1. To plot the spectrum of a pulse of width 10

To verify following properties of Fourier


2. Transform-Time, Frequency, Convolution
Shift
Study of uniform, exponential and Gaussian
3. distributed random variables. Draw their pdf
and CDF.
4. Study of linear and non-linear quantization.

Study of passband digital communication


5. technique BPSK. Calculate the BER of the
BPSK modulated signal.
Find Code Set C for given Generator Matrix G
6. and also determine the
generator matrix G′ of the appropriate
systematic (separable) code C’.
Model a single- queue single-server system with
7. a single traffic source and an infinite storage
capacity.
Model a single- queue single-server system that
8. has a Poisson arrival process and a server with
constant service time.
Experiment 1) To plot the spectrum of a pulse of width 10

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,

Then, according to the time-shifting property of Fourier transform,

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,

Then, according to the linearity property of Fourier transform,

Where a and b are constants.

iii) Convolution Shift: The convolution of two signals in time domain is equivalent to the
multiplication of their spectra in frequency domain. Therefore, if

Then, according to time convolution property of Fourier transform,


Code:-

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

clc; clear all; close all;


% Frequency Shifting Propert of Fourier Transform:
x=input('Enter the Sequence x:');
l=input('Enter no Shifted by 1:');
N=length(x); Y=fft(x);
Y3=abs(Y);
for n=1:N
x1(n)=x(n)*exp(-1j*2*pi*1/N);
end
Y1=fft(x1);
Y2=abs(Y1);
for n=1:N
z(n)=atan(real(Y(n))/imag(Y(n)));
z1(n)=atan(real(Y1(n))/imag(Y1(n)));
end
subplot(2,2,1);
stem(Y3);
ylabel('Amplitude');
xlabel('DFT coefficent numbers');
title('Magnitude Spectrum');
subplot(2,2,2);
stem(Y2);
ylabel('Amplitude');
xlabel('DFT coefficent numbers');
title('Magnitude Spectrum');
subplot(2,2,3);
stem(z);
ylabel('Angle');
xlabel('DFT coefficent numbers');
title('Phase Spectrum');
subplot(2,2,4);
stem(z1);
ylabel('Angle');
xlabel('DFT coefficent numbers');
title('Phase Spectrum');

Enter the Sequence x:


[1,2,3,4,5,6]
Enter no Shifted by 1:
2
c) Convolution

CODE :-

clc; clear all; close all;


n1 = 1:10;
u = sin(n1);
n2 = 1:10;
v = cos(n2);
x = conv(u,v);
N = length(x);
f = fft(x,N);
w = 2*pi/N:2*pi/N:2*pi;
subplot(2,1,1);
stem(f);
N1 = length(u);
f1 = fft(u,N1);
N2 = length(v);
f2 = fft(v,N2);
y = f1.*f2;
N3 = length(y);
subplot(2,1,2);
stem(y);
EXPERIMENT 3 ) Study of exponential distributed random variables. Draw their
pdf and CDF.

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.

The probability density function (pdf) of an exponential distribution is

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

You might also like