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

📄 lab24b.m

📁 32qam modulation with gray code on Monte Carlo
💻 M
字号:

function [ber, numBits] = bertooltemplate(EbNo, maxNumErrs, maxNumBits)
% Import Java class for BERTool.
import com.mathworks.toolbox.comm.BERTool;

% Initialize variables related to exit criteria.
totErr = 0;  % Number of errors observed
numBits = 0; % Number of bits processed

% --- Set up parameters. ---
% --- INSERT YOUR CODE HERE.
N_symbols = 10000; % Number of symbols in the calculation
M=32;
N_samples_per_symbol=8;
% Simulate until number of errors exceeds maxNumErrs
% or number of bits processed exceeds maxNumBits.
while((totErr < maxNumErrs) && (numBits < maxNumBits))

   % Check if the user clicked the Stop button of BERTool.
   if (BERTool.getSimulationStop)
      break;
   end

   % --- Proceed with simulation.
   % --- Be sure to update totErr and numBits.
   % --- INSERT YOUR CODE HERE.
    % genere data
    x=randsrc(N_symbols,1,0:M-1);
    %Modulation 32QAM
    y=qammod(x,M,0,'gray');
    %calcule SNR
    SNR = EbNo + 10*log10(log2(M)) - 10*log10(N_samples_per_symbol);
    %genre rectpulse
    ytx=rectpulse(y,N_samples_per_symbol);
    %Ajoute le bruit
    yrx=awgn(ytx,SNR,'measured');%%Channel type
    
    %intdump au reception
    ymf=intdump(yrx,N_samples_per_symbol);
    %Demodulation
    x_estimate=qamdemod(ymf,M,0,'gray');
    
    %calcule nombre d'erreurs
    [number_of_errors,bit_error_rate] = biterr(x,x_estimate);
    
     %% Update totErr and numBits.
   totErr = totErr + number_of_errors;
   numBits = numBits + N_symbols*log2(M) ;

    
end % End of loop

% Compute the BER.
ber = totErr/numBits;

⌨️ 快捷键说明

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