www.pudn.com > ldpc802.16.rar > test_iid_fading_pureldpc.m, change:2005-10-28,size:1875b


close all; 
% clear all; 
 
seed=randint(1,1,100000); 
seed=13058; 
randn('state',seed); 
rand('state',seed); 
 
snr=9; %dB 
 
load matr960_720_3 
load matr960_720_3g 
 
[m,n]=size(H); 
 
N=8;  
Nc=8; 
sym_num=(n-m)*Nc; 
tone_num=(n-m)*N; 
W=hadamard(N)/sqrt(N); 
mod_sch='qask'; 
mod_order=4; 
 
trial=10; 
 
for sn=1:length(snr) 
    disp(['snr=',num2str(snr(sn))]); 
    tic; 
    percount=0; 
    for tr=1:trial 
        bit=randint(sym_num,1); 
         
        % encoding 
        for i=1:Nc 
            tmp=bit((i-1)*(n-m)+1:i*(n-m)); 
            bit1((i-1)*n+1:i*n)=ldpc_encode(tmp,G,2); 
        end 
 
        sym=reshape(bit1,2,length(bit1)/2)'; 
        sym=bi2de(sym,'left-msb'); 
        s=qammod4(sym); 
 
        %channel 
        h=randn(size(s))+sqrt(-1)*randn(size(s)); 
        h=h/sqrt(mean(abs(h).^2));%*10^(snr/20); 
 
        %iid channel 
        x=s.*h; 
 
        % add noise 
%         seed=13058; 
%         randn('state',seed); 
%         rand('state',seed); 
 
        x=awgn(x,snr(sn),0); 
 
        % demodulation 
        demod=qamdemod4soft_h(x,h,10^(-snr(sn)/10)); 
 
%         de=demod>0.5; 
%         de=reshape(de,2,length(de)/2)'; 
%         desym=bi2de(de,'left-msb'); 
%         err=desym-sym; 
%         sercount=length(find(err)~=0); 
%         ser=sercount/length(err) 
        x1=x./h; 
        sd=(sign(real(x1))+sqrt(-1)*sign(imag(x1)))*0.7071; 
        err=sd-s; 
        ser=length(find(err))/length(err) 
 
        % decoding 
        for i=1:Nc 
            tmp=demod((i-1)*n+1:i*n); 
            [zz,succ,kk]=ldpc_decode(tmp,H,2); 
            debit((i-1)*(n-m)+1:i*(n-m))=zz(size(G,2)+1-size(G,1):size(G,2));; 
            if succ~=1 
                percount=percount+1; 
            end 
        end 
    end 
    bler(sn)=percount/(trial*Nc) 
    err=debit-bit'; 
    ber=length(find(err))/length(err) 
    toc 
end