Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save IamMuhammadHasib/3c7bfc02411b23119202a10d5089dfeb to your computer and use it in GitHub Desktop.
Save IamMuhammadHasib/3c7bfc02411b23119202a10d5089dfeb to your computer and use it in GitHub Desktop.
Line Coding

Signal Convertion with Line Coding Technique

In MatLab

alt text

load input.txt;
m = input;
n = length(m);
x = [];
y = [];
for i=1:n
x=[x i-1 i];
if(m(i)==0)
y=[y 0 0];
else
y=[y 1 1];
end
end
plot(x,y),axis([0,n,-2,2]);
title('Unipolar NRZ');
# tasfik
load input.txt;
m = input;
n = length(m);
x = [];
y = [];
for i=1:n
x=[x i-1 i];
if(m(i)==0)
y=[y 1 1];
else
y=[y -1 -1];
end
end
plot(x,y),axis([0,n,-2,2]);
title('Polar NRZ L');
m = [0 1 0 0 1 1 1 0];
n = length(m);
x = [];
y = [];
a=1;
for i=1:n
x=[x i-1 i];
if(m(i)==1)
y=[y -a -a];
else
y=[y a a];
end
a=y(length(y));
end
plot(x,y),axis([0,n,-2,2]);
title('Polar NRZ I');
m = [0 1 0 0 1];
n = length(m);
x = [];
y = [];
for i=1:n
x=[x i-1 i-1+0.5 i-1+0.5 i];
if(m(i)==0)
y=[y -1 -1 0 0];
else
y=[y 1 1 0 0];
end
end
plot(x,y),axis([0,n,-2,2]);
title('Polar RZ');
m = [0 1 0 0 1 1];
n = length(m);
x = [];
y = [];
for i=1:n
x=[x i-1 i-1+0.5 i-1+0.5 i];
if(m(i)==0)
y=[y 1 1 -1 -1];
else
y=[y -1 -1 1 1];
end
end
plot(x,y),axis([0,n,-2,2]);
title('Manchester');
m = [0 1 0 0 1 1];
n = length(m);
x = [];
y = [];
a = 1;
for i=1:n
x=[x i-1 i-1+0.5 i-1+0.5 i];
if(m(i)==0)
y=[y -a -a a a];
else
y=[y a a -a -a];
end
a=y(length(y));
end
plot(x,y),axis([0,n,-2,2]);
title('Differential Manchester');
m = [0 1 0 0 1 0];
n = length(m);
x = [];
y = [];
a=1;
for i=1:n
x=[x i-1 i];
if(m(i)== 1)
y=[y a a];
a=a*(-1);
else
y=[y 0 0];
end
end
plot(x,y),axis([0,n,-2,2]);
title('Bipolar AMI');
m = [0 1 0 0 1 0];
n = length(m);
x = [];
y = [];
a=1;
for i=1:n
x=[x i-1 i];
if(m(i)== 0)
y=[y a a];
a=a*(-1);
else
y=[y 0 0];
end
end
plot(x,y),axis([0,n,-2,2]);
title('Bipolar Pseudoternary / opposite of AMI');
m = [0 1 0 1 1 0 1 1];
n = length(m);
x = [];
y = [];
cur_lvl=0;
last_non_zero_lvl=-1;
for i=1:n
x=[x i-1 i];
if(m(i)==0)
y=[y cur_lvl cur_lvl];
else
if(cur_lvl~=0)
y=[y 0 0];
cur_lvl=0;
else
y=[y -last_non_zero_lvl -last_non_zero_lvl];
last_non_zero_lvl = last_non_zero_lvl*(-1);
cur_lvl = last_non_zero_lvl;
end
end
end
plot(x,y),axis([0,n,-2,2]);
title('MLT-3');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment