📄 gendopplererrorberdata.m
字号:
function [] = GenDopplerErrorBerData(gammaRangeAwgn,gammaRangeRayleigh,dopplerRange,saveFile)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This function plots the BER for QAM modulation, with doppler bias in
% the receiver.
%
% gammaRangeAwgn = the Es/No range for AWGN plotting, in dB. gammaRangeAwgn(1) = min value,
% gammaRangeAwgn(2) = max value, gammaRangeAwgn(3) = granularity
% gammaRangeRayleigh = the average Es/No range for Rayleigh plotting, in dB. Analogous to
% gammaRangeAwgn
% dopplerRange = the doppler range for both AWGN and Rayleigh plots.
% dopplerRange(1) = min value, dopplerRange(2) = max value. dopplerRange(3) = granularity.
% dopplerRange(4) = T. First 3 values in radians/symbol. Fourth value in number of symbols.
% All values assumed positive. By symmetry, negative values
% yield the same results.
% saveFile = filename where the computed values shall be stored. Allows for later
% analysis without re-running simulations. If saveFile = '', then
% data is not saved.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%NUM_SYMB_LIMIT = 100000;
BER_LIMIT = 0.00001
gammaSamplesAwgn = floor((gammaRangeAwgn(2)-gammaRangeAwgn(1))/gammaRangeAwgn(3)) + 1;
gammaSamplesRayleigh = floor((gammaRangeRayleigh(2)-gammaRangeRayleigh(1))/gammaRangeRayleigh(3))+1;
dopplerSamples = floor(((dopplerRange(2)-dopplerRange(1))/dopplerRange(3)))+1;
% in the following matrix, the third index indicates if it is a theoretical or simulated value,
% the fourth index indicates if it is AWGN or Rayleigh on AWGN. Index = 1 means the former,
% index = 2 means the latter.
ber = zeros(max([gammaSamplesAwgn,gammaSamplesRayleigh]),dopplerSamples,2,2);
% Compute AWGN BER values from theoretical equation
dopplerIndex = 1;
for doppler = dopplerRange(1):dopplerRange(3):dopplerRange(2)
gammaIndex = 1;
for gamma = gammaRangeAwgn(1):gammaRangeAwgn(3):gammaRangeAwgn(2)
ber(gammaIndex,dopplerIndex,1,1) = BerAwgnDoppler(((10^(gamma/10))/2),0,doppler*dopplerRange(4));
gammaIndex = gammaIndex + 1;
end
dopplerIndex = dopplerIndex + 1;
end
% Compute Rayleigh BER values from theoretical equation
dopplerIndex = 1;
for doppler = dopplerRange(1):dopplerRange(3):dopplerRange(2)
gammaIndex = 1;
for gamma = gammaRangeRayleigh(1):gammaRangeRayleigh(3):gammaRangeRayleigh(2)
ber(gammaIndex,dopplerIndex,1,2) = BerRayleighDoppler(((10^(gamma/10))/2),doppler*dopplerRange(4));
gammaIndex = gammaIndex + 1;
end
dopplerIndex = dopplerIndex + 1;
end
% Compute AWGN BER values from simulations
dopplerIndex = 1;
for doppler = dopplerRange(1):dopplerRange(3):dopplerRange(2)
gammaIndex = 1;
for gamma = gammaRangeAwgn(1):gammaRangeAwgn(3):gammaRangeAwgn(2)
if (ber(gammaIndex,dopplerIndex,1,1) > BER_LIMIT)
% Use the theoretical BER for a guess of the appropriate number of symbols
numSymb = round(100/ber(gammaIndex,dopplerIndex,1,1))
if (numSymb > dopplerRange(4))
numIters = round(numSymb/dopplerRange(4));
%break;
else
numIters = 1;
end
numSymb = dopplerRange(4);
ber(gammaIndex,dopplerIndex,2,1) = 0;
for jj = 1:numIters
[tempBer,ser] = basicModDemod(gamma,0,numSymb,0,doppler);
ber(gammaIndex,dopplerIndex,2,1) = ber(gammaIndex,dopplerIndex,2,1) + tempBer;
end
ber(gammaIndex,dopplerIndex,2,1) = ber(gammaIndex,dopplerIndex,2,1)/numIters;
%[ber(gammaIndex,dopplerIndex,2,1),ser] = basicModDemod(gamma,0,numSymb,doppler);
end
% Save data
if (~isempty(saveFile))
save(saveFile);
end
gammaIndex = gammaIndex + 1;
end
dopplerIndex = dopplerIndex + 1;
end
% Compute Rayleigh BER values from simulations
dopplerIndex = 1;
for doppler = dopplerRange(1):dopplerRange(3):dopplerRange(2)
gammaIndex = 1;
for gamma = gammaRangeRayleigh(1):gammaRangeRayleigh(3):gammaRangeRayleigh(2)
if (ber(gammaIndex,dopplerIndex,1,2) > BER_LIMIT)
% Use the theoretical BER for a guess of the appropriate number of symbols
numSymb = round(100/ber(gammaIndex,dopplerIndex,1,2))
if (numSymb > dopplerRange(4))
numIters = round(numSymb/dopplerRange(4));
%break;
else
numIters = 1;
end
numSymb = dopplerRange(4);
ber(gammaIndex,dopplerIndex,2,2) = 0;
for jj = 1:numIters
[tempBer,ser] = basicModDemod(gamma,1,numSymb,0,doppler);
ber(gammaIndex,dopplerIndex,2,2) = ber(gammaIndex,dopplerIndex,2,2) + tempBer;
end
ber(gammaIndex,dopplerIndex,2,2) = ber(gammaIndex,dopplerIndex,2,2)/numIters;
end
% Save data
if (~isempty(saveFile))
save(saveFile);
end
gammaIndex = gammaIndex + 1;
end
dopplerIndex = dopplerIndex + 1;
end
% Save data
if (~isempty(saveFile))
save(saveFile);
end
DopplerErrorBerPlotter;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -