www.pudn.com > ldpc802.16.rar > transceiver_awgn_ldpc_mcwill.m, change:2005-11-11,size:2164b


clear all; 
close all 
 
seed=randint(1,1,100000); 
% seed=77705; 
randn('state',seed); 
rand('state',seed); 
 
load ldpc_mcwill.mat 
 
mod_order=4; 
snr=[1.5,2,2.5]; 
EbN0=1.75; 
 
z=[96,72,48,24,12]; 
zmax=96; 
% H1=ldpc_genHbm_3gpp(ldpc_mcwill,zmax,z); 
% H=ldpc_genH_3gpp(H1,z); 
 
% [m,n]=size(H); 
% s=randint(1,(n-m)); 
% s1=ldpc_encode_80216e(s,H1,z); 
% check=sum(rem(H*s1,2)); 
% [zz,suc,k]=ldpc_decode(s1,H,2); 
 
for fa=1:length(z) 
     
    H1=ldpc_genHbm_3gpp(ldpc_mcwill,zmax,z(fa)); 
    H=ldpc_genH_3gpp(H1,z(fa)); 
    [m,n]=size(H); 
     
    for sn=1:length(snr) 
        bercount=0; 
        percount=0; 
        len=0; 
 
        disp(['snr=',num2str(snr(sn))]); 
        tic; 
        for tr=1:1e4 
            bit=randint(n-m,1); 
 
            %Encoding 
            cbit=ldpc_encode_80216e(bit,H1,z(fa)); 
 
            %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)); 
            %         demsym=qamdemod4soft_2bpsk(rsym,10^(-snr(sn)/10)); 
            %         demsym=bpskdemodsoft(rsym,sqrt(1/(2*1/2*10^(EbN0/10)))); 
 
            %Decoding 
            [zz,suc,kk]=ldpc_decode(demsym,H,2); 
            x=zz(1:(n-m)); 
 
            %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((fa-1)*2+sn)=bercount/len 
        per((fa-1)*2+sn)=percount/(len/(n-m)) 
        len 
 
        toc 
    end 
end 
save mcwill_performance ber per