0% found this document useful (0 votes)
70 views6 pages

Muhammad Haseeb Iftikhar: Line Coding

The document describes MATLAB code functions for implementing different line coding schemes: NRZ, BIP-NRZ, RZ, BIP-RZ, Manchester, and AMI. The functions take binary data as an input and output the encoded signal, along with a clock and the original data for comparison purposes. Common aspects of the functions include setting the signal level, plotting the input data, clock and encoded output signal over time for analysis and comparison of each coding scheme.

Uploaded by

haseebiftikhar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views6 pages

Muhammad Haseeb Iftikhar: Line Coding

The document describes MATLAB code functions for implementing different line coding schemes: NRZ, BIP-NRZ, RZ, BIP-RZ, Manchester, and AMI. The functions take binary data as an input and output the encoded signal, along with a clock and the original data for comparison purposes. Common aspects of the functions include setting the signal level, plotting the input data, clock and encoded output signal over time for analysis and comparison of each coding scheme.

Uploaded by

haseebiftikhar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

MUHAMMAD HASEEB IFTIKHAR

10-ENC-49
LINE CODING:

NRZ:
function nrz(d)
l=length(d);
t=1:l;
lev=5;
tc=1:.5:(l+0.5);
clk=[1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ];
y=[zeros(1,l)];
subplot(3,1,1);
stairs(t,d,'linewidth',2);
axis([1 l 0 1.2]);
title('DATA','fontweight','Bold');
subplot(3,1,2);
stairs(tc,clk,'linewidth',2);
axis([1 l 0 1.2]);
title('CLOCK','fontweight','Bold');
for k=1:l
if d(k)==1
y(k)=lev;
else
y(k)=0;
end
subplot(313)
text(k+0.5,lev+1.3,num2str(d(k)),...
'fontweight','bold')
hold on
end
stairs(t,y,'linewidth',2);
axis([1 l 0 lev+3]);
title('NRZ','fontweight','bold');
grid on

M HASEEB IFTIKHAR
DEPT. OF ELECTRONICS ENGINEERING
University of Engineering and Technology, Taxila
PAKISTAN

BIP-NRZ
function bip_nrz(d)
l=length(d);
t=1:l;
lev=5;
tc=1:.5:(l+0.5);
clk=[1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ];
y=[zeros(1,l)];
subplot(3,1,1);
stairs(t,d,'linewidth',2);
axis([1 l 0 1.2]);
title('DATA','fontweight','Bold');
subplot(3,1,2);
stairs(tc,clk,'linewidth',2);
axis([1 l 0 1.2]);
title('CLOCK','fontweight','Bold');
for k=1:l
if d(k)==1
y(k)=lev;
else
y(k)=-lev;
end
subplot(313)
text(k+0.5,lev+1.3,num2str(d(k)),...
'fontweight','bold')
hold on
end
stairs(t,y,'linewidth',2);
axis([1 l -lev-1 lev+3]);
title('BIP-NRZ','fontweight','bold');
grid on

RZ
function rz(d)
l=length(d);
t=1:l;
lev=5;
tc=1:.5:(l+0.5);
clk=[1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ];
y=[zeros(1,2*l)];
subplot(3,1,1);
stairs(t,d,'linewidth',2);
axis([1 l 0 1.2]);
title('DATA','fontweight','Bold');
subplot(3,1,2);
stairs(tc,clk,'linewidth',2);
axis([1 l 0 1.2]);
title('CLOCK','fontweight','Bold');
for k=1:l
if d(k)==1
y(2*k-1)=lev;
y(2*k)=0;
else
y(2*k-1)=0;
end
subplot(313)
text(k+0.3,lev+1.3,num2str(d(k)),...
'fontweight','bold')
hold on
end
stairs(tc,y,'linewidth',2);
axis([1 l 0 lev+3]);
title('RZ','fontweight','bold');
grid on

BIP-RZ
function b_rz(d)
l=length(d);
t=1:l;
lev=5;
tc=1:.5:(l+0.5);
clk=[1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ];
y=[zeros(1,2*l)];
subplot(3,1,1);
stairs(t,d,'linewidth',2);
axis([1 l 0 1.2]);
title('DATA','fontweight','Bold');
subplot(3,1,2);
stairs(tc,clk,'linewidth',2);
axis([1 l 0 1.2]);
title('CLOCK','fontweight','Bold');
for k=1:l
if d(k)==1
y(2*k-1)=lev;
y(2*k)=-lev;
else
y(2*k-1)=-lev;
y(2*k)=-lev;
end
subplot(313)
text(k+0.3,lev+1.3,num2str(d(k)),...
'fontweight','bold')
hold on
end
stairs(tc,y,'linewidth',2);
axis([1 l -lev-1 lev+3]);
title('BIP-RZ','fontweight','bold');
grid on

MANCHASTER
function manc(d)
l=length(d);
t=1:l;
lev=5;
tc=1:.5:(l+0.5);
clk=[1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ];
y=[zeros(1,2*l)];
subplot(3,1,1);
stairs(t,d,'linewidth',2);
axis([1 l 0 1.2]);
title('DATA','fontweight','Bold');
subplot(3,1,2);
stairs(tc,clk,'linewidth',2);
axis([1 l 0 1.2]);
title('CLOCK','fontweight','Bold');
for k=1:l
if d(k)==1
y(2*k-1)=lev;
y(2*k)=0;
else
y(2*k-1)=0;
y(2*k)=lev;
end
subplot(313)
text(k+0.3,lev+1.3,num2str(d(k)),...
'fontweight','bold')
hold on
end
stairs(tc,y,'linewidth',2);
axis([1 l 0 lev+3]);
title('MANCHESTER','fontweight','bold');
grid on

AMI
function ami(d)
l=length(d);
t=1:l;
lev=5;
flag=0;
tc=1:.5:(l+.5);
clk=[1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ];
y=[zeros(1,2*l)];
subplot(3,1,1);
stairs(t,d,'linewidth',2);
axis([1 l 0 1.2]);
title('DATA','fontweight','Bold');
subplot(3,1,2);
stairs(tc,clk,'linewidth',2);
axis([1 l 0 1.2]);
title('CLOCK','fontweight','Bold');
for k=1:l
if d(k)==1
if flag==0
y(2*k-1)=lev;
y(2*k)=0;
flag=1;
else
y(2*k-1)=-lev;
y(2*k)=0;
flag=0;
end
else
y(2*k-1)=0;
end
subplot(313)
text(k+0.3,lev+1.3,num2str(d(k)),...
'fontweight','bold')
hold on
end
stairs(tc,y,'linewidth',2);
axis([1 l -lev-1 lev+3]);
title('AMI','fontweight','bold');
grid on

You might also like