%file name: hammda.m %Written by Dr. James S. Kang, Cal Poly Pomona. %Calculate the message u for the given received vector r %when Hamming code is used. %r = received vector such as [1 1 0 1 0 0 1]. %To run the program, try % >>hammda([1 1 0 1 0 0 1]) function[H,G,u] = hammda(r) n=size(r,2); %n = length of r. m=ceil(log(n)/log(2)); k=n-m; Im=eye(m); Q=zeros(m,k); nc = 0; %nc = number of columns in Q matrix. count=0; d=zeros(m)'; while nc < k count=count+1; b=dec2bin(count); if sum(b)>1 nc=nc+1; s=size(b,1); if s