www.pudn.com > ldpc802.16.rar > transceiver_awgn_ldpc_80216e.m, change:2005-12-19,size:1992b


clear all; 
close all 
 
seed=randint(1,1,100000); 
% seed=77705; 
randn('state',seed); 
rand('state',seed); 
 
load ldpc_80216e_66r3_r34 
 
Rate=1-size(ldpc_80216e,1)/size(ldpc_80216e,2); 
mod_order=4; 
EbN0=[3.5]; 
snr=EbN0+10*log10(log2(mod_order)*Rate); 
 
z=24; 
zmax=96; 
H1=ldpc_genHbm_3gpp(ldpc_80216e,zmax,z); 
H=ldpc_genH_3gpp(H1,z); 
 
[m,n]=size(H1); 
% s=randint(1,(n-m)*z); 
% s1=ldpc_encode_80216e(s,H1,z); 
% check=sum(rem(H*s1,2)); 
% [zz,suc,k]=ldpc_decode(s1,H,2); 
 
for sn=1:length(snr) 
    bercount=0; 
    percount=0; 
    len=0; 
     
    disp(['snr=',num2str(snr(sn))]); 
    tic; 
    for k=1:1e2 
        infonum=n-m; 
        bit=randint(infonum*z,1); 
 
        %Encoding 
        cbit=ldpc_encode_80216e(bit,H1,z); 
 
        %Modulation 
        sym=reshape(cbit,log2(mod_order),length(cbit)/log2(mod_order))'; 
        sym=bi2de(sym,'left-msb'); 
        msym=qammod4(sym); 
%         msym=bpskmod(cbit); 
 
        %Channel         
        rsym=awgn(msym,snr(sn)); 
%         rsym=msym+sqrt(1/(2*1/2*10^(EbN0/10)))*randn(size(msym)); 
 
        %Add interference 
%         P=10^(-sinr/10)-10^(-snr/10); 
%         rsym=rsym+qammod4(randint(1,length(rsym),mod_order))*sqrt(P).*exp(sqrt(-1)*2*pi*rand(1,length(rsym))); 
 
        %Demodulation 
        demsym=qamdemod4soft(rsym,10^(-snr(sn)/10),'LLR'); 
%         demsym=qamdemod4soft_2bpsk(rsym,10^(-snr(sn)/10)); 
%         demsym=bpskdemodsoft(rsym,sqrt(1/(2*1/2*10^(EbN0/10)))); 
 
        %Decoding 
%         tic 
        [zz,suc,kk]=ldpc_decode_llr(demsym,H,2); 
%         [zz,suc,kk]=ldpc_decode_bp_based(demsym,H,2); 
%         toc 
        x=zz(1:(n-m)*z); 
 
        %Error calculate 
        bererr=x(:)-bit(:); 
        bercount=bercount+length(find(bererr(:))); 
        len=len+length(bererr(:)); 
         
        if length(find(bererr))~=0 
            percount=percount+1; 
        end 
    end 
    ber(sn)=bercount/len 
    per(sn)=percount/(len/(n-m)/z) 
    len 
     
    toc 
end