0% found this document useful (0 votes)
47 views3 pages

Manchester/Bi-phase:: All All

The document contains MATLAB code that generates different line codes for a binary data sequence. It produces Manchester, bipolar, and polar line codes in both non-return-to-zero (NRZ) and return-to-zero (RZ) formats by manipulating the input binary sequence and plotting the output waveform.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views3 pages

Manchester/Bi-phase:: All All

The document contains MATLAB code that generates different line codes for a binary data sequence. It produces Manchester, bipolar, and polar line codes in both non-return-to-zero (NRZ) and return-to-zero (RZ) formats by manipulating the input binary sequence and plotting the output waveform.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Manchester/Bi-phase:

clc;
close all;
clear all;
x=[1 0 0 1 1 0 1 0 1 0];
T=length(x);
n=100;
N=2*n*T;
dt=T/N;
t=0:dt:T;
y=zeros(1,length(t));
for i=0:1:(T-1);
if x(i+1)==1
y(i*2*n+1 : (2*i+1)*n)=1;
y((i*2+1)*n+1 : (2*i+2)*n)=-1;
else
y(i*2*n+1 : (2*i+1)*n)=-1;
y((2*i+1)*n+1 : (2*i+2)*n)=1;
end;
end;
figure
plot(t,y);
axis([0 t(end) -1.5 1.5]);
grid on;
title('Manchester NRZ');

for i=0:1:(T-1);
if x(i+1)==1
y(i*2*n+1 : (2*i+1)*n)=1;
y((i*2+1)*n+1 : (2*i+2)*n)=0;
else
y(i*2*n+1 : (2*i+1)*n)=-1;
y((2*i+1)*n+1 : (2*i+2)*n)=0;
end;
end;
figure
plot(t,y);
axis([0 t(end) -1.5 1.5]);
grid on;
title('Manchester RZ');

Bipolar/AMI:

clc;
clear all;
close all;
x=[1 0 0 1 1 0 1 0 1 0];
T=length(x);
n=100;
N=2*n*T;
dt=T/N;
t=0:dt:T;
y=zeros(1,length(t));
prev=1;
for i=0:1:(T-1);
if x(i+1)==1
y(i*2*n+1 : (2*i+1)*n)=prev;
y((i*2+1)*n+1 : (2*i+2)*n)=0;
prev=-prev;
else
y(i*2*n+1 : (2*i+2)*n)=0;
end;
end;
figure
plot(t,y);
axis([0 t(end) -1.5 1.5]);
grid on;
title('bipolar RZ');

prev=1
for i=0:1:(T-1);
if x(i+1)==1
y(i*2*n+1 : (2*i+2)*n)=prev;
prev=-prev;
else
y(i*2*n+1 : (2*i+2)*n)=0;
end;
end;
figure
plot(t,y);
axis([0 t(end) -1.5 1.5]);
grid on;
title('bipolar NRZ');

Polar:

clc;
close all;
clear all;
x=[1 0 0 1 1 0 1 0 1 0];
T=length(x);
n=100;
N=2*n*T;
dt=T/N;
t=0:dt:T;
y=zeros(1,length(t));
for i=0:1:(T-1);
if x(i+1)==1
y(i*2*n+1 : (2*i+2)*n)=1;
else
y(i*2*n+1 : (2*i+2)*n)=-1;
end;
end;
figure
plot(t,y);
axis([0 t(end) -1.5 1.5]);
grid on;
title('Polar NRZ');

for i=0:1:(T-1);
if x(i+1)==1
y(i*2*n+1 : (2*i+1)*n)=1;
y((i*2+1)*n+1 : (2*i+2)*n)=0;
else
y(i*2*n+1 : (2*i+1)*n)=-1;
y((2*i+1)*n+1 : (2*i+2)*n)=0;
end;
end;
figure
plot(t,y);
axis([0 t(end) -1.5 1.5]);
grid on;
title('Polar RZ');

You might also like