% bit check clear; % input active group load 'activegroup' groupname; groupname % input original size filename=sprintf('%s_Bsize.mat',groupname); load (filename) % retrieve matrix size filename Nbitb4=Nbit Nseqb4=Nseq % input original bit matrix filename=sprintf('%s_B.mat',groupname); load (filename); % load bitcheck filename=sprintf('%s_Bcheck.mat',groupname); load (filename); % load received signal filename=sprintf('%s_Bs.mat',groupname); load (filename); % check for consistancy [Nseqnow,N]=size(Bs); N if Nseqnow~=Nseqb4 'ERROR:bitcheck matrices inconsistant' else 'OK: bitcheck matrices consistant' end; % plot k=1:N; for f=1:Nseq figure(f); bs1(1:N)=Bs(f,1:N); bcheck1(1:N)=Bcheck(f,1:N); k1=1:128; bs1temp(1:128)=bs1(1:128); bcheck1temp(1:128)=bcheck1(1:128); plot(k1,bs1temp,k1,bcheck1temp); end; % loop through bits Btest=zeros(Nseq,Nbit); miss=0; false=0; Nerror=0; nbreceived=0; for m=1:Nseq nb=1; for n=1:N if Bcheck(m,n) > 0.5 % "1" should be present in check signal if Bs(m,n)>0.5 Btest(m,nb)=1; else 'ERROR, missing 1' 'Bcheck' Bcheck(m,n) 'Bs' Bs(m,n) m n nb if Nerror<10 figure(1+Nseq+Nerror); istart=n-(2*N/Nbit); istop=n+(2*N/Nbit); if istart<1 istart=1 end; if istop>N istop=N end; clear x; x=1:(1+istop-istart); btemp=x; bchecktemp=x; btemp(1:(1+istop-istart))=Bs(m,istart:istop); bchecktemp(1:(1+istop-istart))=Bcheck(m,istart:istop); plot(x,btemp,x,bchecktemp); %clear x,btemp,bchecktemp; end; miss=miss+1; Nerror=Nerror+1; end; nb=nb+1; nbreceived=nbreceived+1; end; if Bcheck(m,n) < -0.5 % "-1" should be present in check signal if Bs(m,n) < 0.5 % "0" is present demodulated/binarized signal Btest(m,nb)=0; else 'ERROR, missing 0' 'Bcheck' Bcheck(m,n) 'Bs' Bs(m,n) m n nb if Nerror<10 figure(1+Nseq+Nerror); istart=n-(2*N/Nbit); istop=n+(2*N/Nbit); if istart<1 istart=1 end; if istop>N istop=N end; clear x; x=1:(1+istop-istart); btemp=x; bchecktemp=btemp; btemp(1:(1+istop-istart))=Bs(m,istart:istop); bchecktemp(1:(1+istop-istart))=Bcheck(m,istart:istop); istart istop size(x) size(btemp) size(bchecktemp) plot(x,btemp,x,bchecktemp); end; false=false+1; Nerror=Nerror+1; end; nb=nb+1; nbreceived=nbreceived+1; end; end; end; nbsent=Nbit*Nseq nbreceived miss false Nerror if nbsent~=nbreceived 'Error between sent and recieved' 'Number of ones and zeros sent' Nones=sum(sum(B)) Nzeros=nbsent-Nones end;