www.pudn.com > ldpc802.16.rar > transceiver_awgn_ldpc.m, change:2006-08-03,size:1325b


clear all 
close all 
 
seed=randint(1,1,100000); 
seed=77705; 
randn('state',seed); 
rand('state',seed); 
 
load matr960_480_3 
load matr960_480_3g 
 
[m,n]=size(H); 
mod_order=4; 
snr=2.4;%[-0.2,0.0,0.2,0.4,0.6]; 
EbN0=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); 
%         msym=bpskmod(cbit); 
 
        %Channel 
        rsym=awgn(msym,snr,10*log10(1)); 
%         rsym=msym+sqrt(1/(2*1/2*10^(EbN0/10)))*randn(size(msym)); 
 
        %Demodulation 
        demsym=qamdemod4soft(rsym,10^(-snr/10),'LLR'); 
%         demsym=bpskdemodsoft(rsym,sqrt(1/(2*1/2*10^(EbN0/10)))); 
 
        %Decoding 
%         [zz,suc,k]=ldpc_decode_igor(rsym,1-demsym,demsym,H); 
        [zz,suc,k]=ldpc_decode_llr(demsym,H,2);k 
        x=zz(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