📄 lab24c.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. ---
M=32;
coding='gray';
N_samples_per_symbol=8; % Oversampling rate
N_symbols = 10000; % Number of symbols in the calculation
%filtre rcosine
[ys,ts] = rcosine(1,N_samples_per_symbol, 'fir/sqrt', 0.3, 3);
% 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
%Genere data Aletoire
x=randsrc(N_symbols,1,0:M-1);
%Modulation 32QAM
y=qammod(x,M,0,coding);
%calcul du SNR
SNR = EbNo + 10*log10(log2(M)) - 10*log10(N_samples_per_symbol);
%Filtrage transmetteur
[ytx,ttx] = rcosflt(y, 1, N_samples_per_symbol, 'filter', ys);
%Ajout du bruit
yb=awgn(ytx,SNR,'measured'); %%Cahnnel Type
%Filtrage au recepteur
[yrx,trx] = rcosflt(yb, 1, N_samples_per_symbol, 'filter/Fs', ys);
% Il faut enlever les transitoires et echantilloner
y_estimate=downsample(yrx(49:(length(yrx)-48)),N_samples_per_symbol);
%demodulation
x_estimate=qamdemod(y_estimate,M,0,coding);
[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 + -