www.pudn.com > hamm.rar > hamm_enc.m
function [out]=hamm_enc(in)
n=length(in);
% the length of n is the 4*m where m is integer
% (7,4)บบร๗
out=[];
if mod(n,4)~=0
n=n+4-mod(n,4)
in=[in zeros(1,4-mod(n,4))];
end
for i=1:n/4
a=in((i-1)*4+1:i*4);
for j=1:4
b=mod(sum(a(1:3)),2);
c=mod(sum(a(2:4)),2);
d=mod(a(1)+a(2)+a(4),2);
end
out=[out a,b,c,d];
end;