⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmse_soft.m

📁 是一个四发四收的球型译码程序
💻 M
字号:
%==========================================
%16QAM;   1/2,3conv;    TX=4;RX=4;  硬判决
%==========================================

clear
Tx=4;
Rx=4;
M=16;
h=modem.qammod(M);
h2=modem.qamdemod(M);
Factor=10;


%L=input('please enter the length of the frame:');
SNRdB=input('please enter SNR:');
lenl=input('please enter the length of bit:');
%SNRdB=90;
%lenl=96;
%len=96*10;
L=1;
%SNRdB=5;
Num_order=M;
for SNRindex=1:length(SNRdB)
    SNRtemp=10.^((SNRdB+3)/10);
    SNR=SNRtemp(SNRindex);
    sigma_n2=sqrt(Tx)/sqrt(SNR);
    len=lenl(SNRindex);
    msg=randint(len,1);
    trel=poly2trellis(3,[6,7]);
    code=convenc(msg,trel);
    y=randintrlv(code,4831);
    Sig_code=buffer(y,Tx*L*log2(M));
    Sym_code=zeros(Tx*L*log2(M),2*len/(Tx*L*log2(M)));
      
    for BloInd=1:2*len/(Tx*L*log2(M))
        % transmit signal
        TxMatrix_bit_src=Sig_code(:,BloInd);
        TxMatrix_bit_map=reshape(TxMatrix_bit_src,Tx*L,log2(M));
        TxMatrix_sym_temp=bi2de(TxMatrix_bit_map);
        TxMatrix_sym=modulate(h,TxMatrix_sym_temp)/sqrt(Factor);
        TxMatrix=reshape(TxMatrix_sym,Tx,L);
      
        %channel
        for i=1:Rx
            Ch=(randn(Tx,L)+sqrt(-1)*randn(Tx,L)).*sqrt(0.5);
            TxPassCh=Ch.*TxMatrix;
            TxSum_temp=sum(TxPassCh);
            for k=1:L
                Ch_Equ(Rx*(k-1)+i,Tx*(k-1)+1:Tx*k)=(Ch(:,k)).';
            end
            Tx_Sum(i,:)=TxSum_temp;
         end
 
          % receive signal 
          RxSig=Tx_Sum+sigma_n2*(randn(Rx,L)+sqrt(-1)*randn(Rx,L))/sqrt(2);
          
            
         
           MLValue0=zeros(Tx*L*log2(M),1);
           MLValue1=zeros(Tx*L*log2(M),1);                      
          
               DetTemp=MIMONCMMSE(RxSig, Ch_Equ,M,sigma_n2,Factor,0);
               
               Tx_sym=modulate(h,DetTemp)/sqrt(Factor);
               Tx_sym_1=reshape(Tx_sym,Tx,L);
               Sigma=2*sigma_n2*sigma_n2;
               Det_bit=de2bi(DetTemp,log2(M),2);
               dd_bit=reshape(Det_bit,Tx*L*log2(M),1);
               for j=1:Tx*L*log2(M)
                   if dd_bit(j,1)==0                    
                      MLValue0(j,1)=MLValue0(j,1)+exp(-norm(RxSig- Ch_Equ*Tx_sym_1,'fro')^2/Sigma);   
                   else
                      MLValue1(j,1)=MLValue1(j,1)+exp(-norm(RxSig- Ch_Equ*Tx_sym_1,'fro')^2/Sigma);
                   end
               end
                    
            %LLR(j)=log(MLValue1/MLValue0);
            NormFactor=sqrt(MLValue1.*MLValue1+MLValue0.*MLValue0);
            MLValue1=MLValue1./NormFactor;
            MLValue0=MLValue0./NormFactor;
            SoftMean=MLValue0-MLValue1;
            %if LLR(j)>=0
            %    dd_bit(1,j)=1;
            %else
            %    dd_bit(1,j)=0;
            %end 
            
            Sym_code(:,BloInd)=SoftMean.';
    end
      
    %Pavg(runs)=mean(D);
    %D=zeros(1,BloInd);
    ncode=reshape(Sym_code,2*len,1);
    b1=randdeintrlv(ncode,4831);
    decoded = vitdec(b1,trel,3,'trunc','unquant'); % Decode. 
    ber(SNRindex)=length(find(decoded-msg))/len; 
end
        


% plot the curve
semilogy(SNRdB, ber);
grid on;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -