You are on page 1of 5

Title: Line Coding

Task No. 5 Santosh kumar

Date-4/10/2020 Regno-18BEC0243

Aim:To generate and analyse line coding of unipolar NRZ,polar NRZ,Bipolar NRZ and
Manchester Polar RZ using MATLAB.

Theory:
Unipolar NRZ 1-a 0-0
Polar NRZ 1-a 0-a
Bipolar NRZ 1-a,-a 0-0
Manchester polar 1=a/2 t0-a/2 0=-a/2 to a/2
Alorithm:
(1) Define the bit sequence
bs=[1 0 1 1 0 1 1 0];
(2) Write condition for unipolar and polar
for i=1:8
if bs(i)==1
uni(i)=2;
polar(i)=2;
else uni(i)=0;
polar(i)=-2;
End
end
(3) Write condition for bipolar
for j=1:8
if bs(j)==1
if flag==0
bip(j)=2;
flag=1;
else bip(j)=-2;
flag=0;
end
else
bip(i)=0;
End
end
(4) Write condition for Manchester polar
for k=1:8
if bs(k)==1
manch(2*k-1)=2;
manch(2*k)=-2;
else
manch(2*k-1)=-2;
manch(2*k)=2;
end
end
(5) Now plot the graph for uipolar,polar,biolar and Manchester using plot and
subplot function

Result:Hence, line code of different technique (unipolar,polar,bipolar and Manchester)


has been drawn.
%santosh kumar reg- 18BEC0243
clc;
clear all;
close all;

bs=[1 0 1 1 0 1 1 0];

for i=1:8
if bs(i)==1
uni(i)=2;
polar(i)=2;
else
uni(i)=0;
polar(i)=-2;
end
end
flag=0;
for j=1:8
if bs(j)==1
if flag==0
bip(j)=2;
flag=1;
else
bip(j)=-2;
flag=0;
end
else
bip(i)=0;
end
end

for k=1:8
if bs(k)==1
manch(2*k-1)=2;
manch(2*k)=-2;
else
manch(2*k-1)=-2;
manch(2*k)=2;
end
end

t=0:1:7;t1=0:0.5:7.5;
subplot(4,1,1);
stairs(t,uni);
title("unipolar");

subplot(4,1,2);
stairs(t,polar);
title("polar");

subplot(4,1,3);
stairs(t1,manch);

1
title("manchester");

subplot(4,1,4);
stairs(t,bip);
title("bipolar");

Published with MATLAB® R2020b

You might also like