Escolar Documentos
Profissional Documentos
Cultura Documentos
LÍNEA EN MATLAB
RESUMEN: El presente artículo tiene como fin simular
algunos de los códigos de línea en Matlab 7.1: AMI, NRZ, RZ,
Bipolar, Unipolar. Asimismo, programar una interfaz gráfica de
usuario (GUIDE) que genere bits aleatorios (hasta 10 bits) para
su posterior codificación (seleccionada por el usuario). De igual
forma, se grafica los espectros de cada uno de los códigos de
línea.
INTRODUCCIÓN
FUNCIÓN UNRZ(h)
El código Unipolar sin retorno a cero representa un 1
lógico (1L) con un nivel de +V durante todo el periodo de bit y
un cero lógico (0L) con un nivel de 0 V durante todo el periodo
de bit. La función siguiente simula esta codificación:
function UNRZ(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('Line code UNIPOLAR NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('zero');
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('Line code UNIPOLAR NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('one');
end
n=n+1;
%pause;
end
FUNCIÓN URZ(h)
FUNCIÓN PNRZ(h)
FUNCIÓN 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('Line code BIPOLAR RZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('zero');
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('Line code BIPOLAR RZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('one');
end
n=n+1;
%pause;
end
FUNCIÓN AMINRZ(h)
end
d=plot(t,y);grid on;
title('Line code AMI NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('one');
end
n=n+1;
%pause;
end
FUNCIÓN AMIRZ(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('Line code AMI RZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('zero');
else
ami=ami*-1;
if h(n+1)==0
if ami==1
y=(t<n-0.5);
else
y=-(t<n-0.5);
end
else
if ami==1
y=(t<n-0.5)-(t==n);
else
y=-(t<n-0.5)+(t==n);
end
end
d=plot(t,y);grid on;
title('Line code AMI RZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('one');
end
n=n+1;
%pause;
end
FUNCIÓN MANCHESTER(h)