Beruflich Dokumente
Kultur Dokumente
CODIGOS DE LINEA
Objetivo:
Mostrar y comparar el los cdigos NRZ unipolar, RZ unipolar, NRZ polar, RZ polar,
AMI NRZ y Manchester.
Procedimiento:
1. Utilizando el workspace escribir en un M-file para representar los siguientes
cdigos:
a) NRZ unipolar
function y=UNRZ(h)
clf;
n=1;
l=length(h);
h(l+1)=1;
while n<=length(h)-1;
T=0.001;
t=n-1:T:n;
if h(n) == 0
if h(n+1)==0
y=(t>n);
else
y=(t==n);
end
d=plot(t,y);grid on;
title('UNIPOLAR NRZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
if h(n+1)==0
y=(t<n)-0*(t==n);
else
y=(t<n)+1*(t==n);
end
d=plot(t,y);grid on;
title('UNIPOLAR NRZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
pause;
end
A continuacin en el workspace escribir h=[ 1 0 0 1 1 0 1 0 1 0 0 1] enter,
luego y=UNRZ(h), pulsar enter varias veces hasta que aparezca toda la
secuencia. (Use la misma secuencia h en todos los dems cdigos)
b) RZ unipolar
function y=URZ(h)
clf;
n=1;
l=length(h);
h(l+1)=1;
while n<=length(h)-1;
t=n-1:0.001:n;
if h(n) == 0
if h(n+1)==0
y=(t>n);
else
y=(t==n);
end
d=plot(t,y);grid on
title('UNIPOLAR RZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
if h(n+1)==0
y=(t<n-0.5);
else
y=(t<n-0.5)+1*(t==n);
end
d=plot(t,y);grid on;
title('UNIPOLAR RZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
pause;
end
end
c) RNZ polar
function y=PNRZ(h)
clf;
n=1;
l=length(h);
h(l+1)=1;
while n<=length(h)-1;
t=n-1:0.001:n;
if h(n) == 0
if h(n+1)==0
y=-(t<n)-(t==n);
else
y=-(t<n)+(t==n);
end
d=plot(t,y);grid on;
title('POLAR NRZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
if h(n+1)==0
y=(t<n)-1*(t==n);
else
y=(t<n)+1*(t==n);
end
d=plot(t,y);grid on;
title('POLAR NRZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
pause;
end
d) RZ polar
function y=BRZ(h)
clf;
n=1;
l=length(h);
h(l+1)=1;
while n<=length(h)-1;
t=n-1:0.001:n;
if h(n) == 0
if h(n+1)==0
y=-(t<n-0.5)-(t==n);
else
y=-(t<n-0.5)+(t==n);
end
d=plot(t,y);grid on;
title('BIPOLAR RZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
if h(n+1)==0
y=(t<n-0.5)-1*(t==n);
else
y=(t<n-0.5)+1*(t==n);
end
d=plot(t,y);grid on;
title('BIPOLAR RZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
pause;
end
e) AMI NRZ
function y=AMINRZ(h)
clf;
n=1;
l=length(h);
h(l+1)=1;
ami=-1;
while n<=length(h)-1;
t=n-1:0.001:n;
if h(n) == 0
if h(n+1)==0
y=(t>n);
else
if ami==1
y=-(t==n);
else
y=(t==n);
end
end
d=plot(t,y);grid on;
title('AMI NRZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
ami=ami*-1;
if h(n+1)==0
if ami==1
y=(t<n);
else
y=-(t<n);
end
else
if ami==1
y=(t<n)-(t==n);
else
y=-(t<n)+(t==n);
end
end
d=plot(t,y);grid on;
title(' AMI NRZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
pause;
end
f) MANCHESTER
function y=MANCHESTER(h)
clf;
n=1;
h=~h;
l=length(h);
h(l+1)=1;
while n<=length(h)-1;
t=n-1:0.001:n;
if h(n) == 0
if h(n+1)==0
y=-(t<n)+2*(t<n-0.5)+1*(t==n);
else
y=-(t<n)+2*(t<n-0.5)-1*(t==n);
end
d=plot(t,y);grid on;
title('MANCHESTER');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
if h(n+1)==0
y=(t<n)-2*(t<n-0.5)+1*(t==n);
else
y=(t<n)-2*(t<n-0.5)-1*(t==n);
end
d=plot(t,y);grid on;
title('MANCHESTER');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
pause;
end