% generate bit matrix based on groupname_Bsize.mat clear; load 'ee64003_Bsize'; % get sizes load 'ee64003_r'; [M,N]=size(r) figure(1) plot(r); % form filter fc=N/8; Norder=8; fmax=N/2; K=1; % filter gain [f H]=lp_butterworth_oN_dft(fc,K,fmax,N,Norder); % filter signal through channel S=fft(r); R=S.*H; rn=real(ifft(R)); % filter the noise with a moving average filter % Symmetric rectangle function for use with DFTs % Ty, Tx are the widths of the rect in the y and x directions % Tx and Ty must be odd values to lead to symmetry properties % My,Nx are the rows (y) and columns (x) of Y, respectively d=size(rn) h=irect(1,(1+N/Nbit),d(1),d(2)); % row vector of rectangular mv filtr H=fft(h); size(H) R=fft(rn); size(R) r=real(ifft(R.*H)); % demodulate first sequence, threshold with 0 level, (pos=1,neg=0) if max(r)>abs(min(r)) range=max(r) else range=abs(min(r)) end scale=1/(range*1.1); r1=r.*scale; % scale in such a way as not to move the zero level b1=ceil(r1); n=1:N; figure(2) plot(n,h,n,r1); % demodulate second sequence r2=abs(r); % flip negative values to positive values Bs=zeros(Nseq,N); Bs(1,1:N)=b1(1:N); figure(3) plot(n,b1); save 'ee64003_Bs' Bs;