www.pudn.com > ldpc802.16.rar > transceiver_awgn_ldpc_3gpp.m, change:2005-09-27,size:1288b


clear all; 
close all 
 
% load ldpc_3gpp_r03.mat 
load ldpc_80216e_66r3_r12.mat 
 
mod_order=4; 
snr=1;%[-0.2,0.0,0.2,0.4,0.6]; 
 
z=48; 
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_3gpp(s,H1,z); 
s1=ldpc_encode_80216e1(s,H1,z); 
check=sum(rem(H*s1,2)); 
[z,succ,k]=ldpc_decode(s1,H,2); 
 
for sn=1:length(snr) 
    bercount=0; 
    len=0; 
     
    disp(['snr=',num2str(snr(sn))]); 
    tic; 
    for k=1:1e4 
        infonum=n-m; 
        bit=randint(infonum,1); 
 
        %Encoding 
        cbit=ldpc_encode(bit,G,2); 
 
        %Modulation 
        sym=reshape(cbit,log2(mod_order),length(cbit)/log2(mod_order))'; 
        sym=bi2de(sym,'left-msb'); 
        msym=qammod4(sym); 
 
        %Channel 
        msym=msym*10^(snr(sn)/20); 
        rsym=msym+sqrt(0.5)*(randn(size(msym))+sqrt(-1)*randn(size(msym))); 
 
        %Demodulation 
        demsym=qamdemod4soft(rsym); 
 
        %Decoding 
        [z,suc,k]=ldpc_decode(demsym,H,2); 
        x=z(size(G,2)+1-size(G,1):size(G,2)); 
 
        %Error calculate 
        bererr=x-bit; 
        bercount=bercount+length(find(bererr(:))); 
        len=len+length(bererr(:)); 
    end 
    ber(sn)=bercount/len 
    len 
     
    toc 
end