Estudiante

Páginas: 2 (324 palabras) Publicado: 2 de diciembre de 2012
DECODIFICADOR DE HAMMING:

clc
clear
disp('*DECODIFICADOR DE HAMMING*')
disp('Seleccione la paridad del decodificador')
pd= input('1. Par \n2.Impar \n \n Paridad:');
while (pd > 2)
clc
disp('Seleccione la paridad del decodificador')
pd= input('1. Par \n 2.Impar \n \n Paridad :');
end
clc
if (pd==1)
bpar=0;bimpar=1;
end
if (pd==2)
bpar=1;
bimpar=0;
end
n= input('Ingrese la longitud de la palabra: ');
clc
for i=1:n
fprintf('Ingrese %d ',i);
pdat(i)=input('bit :');



if (pdat(i) > 1)
fprintf('Ingrese %d ',i);
pdat(i)= input('bit: ');
end
end
clc
disp('La palabra ingresada es :')disp(pdat)
j=n;
for i=1:n
pdat2(i)=pdat(j);
j=j-1;
end
i=1;
m=0;
while (i<=n)
if ((log(i)/log(2))==m)
m=m+1;
end
i=i+1;
end
for i=1:mcont1(i)=0;
end
for j=1:m
a= 2^(j-1);
i=a;
if (((2*a)-1)> n)
lim=n;
else
lim=(2*a)-1;
end
while (i <= n)
for b= i:lim
if(pdat2(b)==1)
cont1(j)=cont1(j)+1;
end
end
i=b+a+1;
if ((i+a-1)> n)
lim=n;
else
lim=i+a-1;
end
end
end
for i=1:mcont2(i)=0;
end
for j=1:m
if (mod(cont1(j),2)==0)
cont2(j)= bpar;
else
cont2(j)=bimpar;
end
end
sum=0;
for i=1:m
x=2^(i-1);t=cont2(i)*x;
sum=sum+t;
end
if(sum~=0)
if (pdat2(sum)==0)
pdat2(sum)=1;
else
pdat2(sum)=0;
end
end
s=1;
j=1;
for i=1:n
if (i~=s)
pdat3(j)=pdat2(i);j=j+1;
else
s=s*2;
end
end
y=length(pdat3);
k=y;
for i=1:y
pdec(i)=pdat3(k);
k=k-1;
end
disp('La palabra decodificada es:')
disp(pdec)
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Estudiante
  • Estudiante
  • Estudiante
  • Estudiante
  • El estudiante
  • Estudiante
  • Estudiante
  • Estudiante

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS