You are on page 1of 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');