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

📄 genmatchedfilterberdata.m

📁 这是一个关于完成QAM调制的Matlab示例程序
💻 M
字号:
function [] = GenMatchedFilterBerData(gammaRangeAwgn,gammaRangeRayleigh,timingRange,saveFile)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This function evaluates the BER for QAM modulation, with matched filter timing error 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
% timingRange = the matched filter timing error range for both AWGN and Rayleigh plots, in number of samples.
%                timingRange(1) = min value, timingRange(2) = max value.  timingRange(3) = granularity.  
%                timingRange(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;
SLOW_FADE_NUM_SYMB_PER_ITER = 100;
BER_LIMIT = 0.00001

gammaSamplesAwgn = floor((gammaRangeAwgn(2)-gammaRangeAwgn(1))/gammaRangeAwgn(3)) + 1;
gammaSamplesRayleigh = floor((gammaRangeRayleigh(2)-gammaRangeRayleigh(1))/gammaRangeRayleigh(3))+1;
timingSamples = floor(((timingRange(2)-timingRange(1))/timingRange(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]),timingSamples,2,2);
if 0
% Need to get the pulse filter coefficients to do error calcs
Frequencies;
%[pulseFilt,delay] = CreatePulseFilter(fs,fd);

% Compute AWGN BER values from theoretical equation
timingIndex = 1;
for timingError = timingRange(1):timingRange(3):timingRange(2)
    gammaIndex = 1;
    for gamma = gammaRangeAwgn(1):gammaRangeAwgn(3):gammaRangeAwgn(2)
        ber(gammaIndex,timingIndex,1,1) = BerAwgnMatchedTimingError(((10^(gamma/10))/2),pulseFilt,timingError,fs/fd,delay);
        gammaIndex = gammaIndex + 1;
    end
    timingIndex = timingIndex + 1;
end    
end %0
% Compute Rayleigh BER values from theoretical equation
timingIndex = 1;
for timingError = timingRange(1):timingRange(3):timingRange(2)
    gammaIndex = 1;
    for gamma = gammaRangeRayleigh(1):gammaRangeRayleigh(3):gammaRangeRayleigh(2)
        ber(gammaIndex,timingIndex,1,2) = BerRayleighMatchedTimingError(((10^(gamma/10))/2),pulseFilt,timingError,fs/fd,delay);
        gammaIndex = gammaIndex + 1;
    end
    timingIndex = timingIndex + 1;
end    

if 0
% Compute AWGN BER values from simulations
timingIndex = 1;
for timingError = timingRange(1):timingRange(3):timingRange(2)
    gammaIndex = 1;
    for gamma = gammaRangeAwgn(1):gammaRangeAwgn(3):gammaRangeAwgn(2)
        if (ber(gammaIndex,timingIndex,1,1) > BER_LIMIT)
           % Use the theoretical BER for a guess of the appropriate number of symbols
           numSymb = round(100/ber(gammaIndex,timingIndex,1,1))
           if (numSymb > NUM_SYMB_LIMIT)
               numIters = round(numSymb/NUM_SYMB_LIMIT);
               numSymb = NUM_SYMB_LIMIT;
            else
                numIters = 1;
            end
            ber(gammaIndex,timingIndex,2,1) = 0;
            for jj = 1:numIters
               [tempBer,ser] = basicModDemod(gamma,0,0,numSymb,0,0,1,timingError);
               ber(gammaIndex,timingIndex,2,1) = ber(gammaIndex,timingIndex,2,1) + tempBer;
            end
            ber(gammaIndex,timingIndex,2,1) = ber(gammaIndex,timingIndex,2,1)/numIters;           
        end
        % Save data
		if (~isempty(saveFile))
            save(saveFile);
		end
        gammaIndex = gammaIndex + 1;
    end
    timingIndex = timingIndex + 1;
end    


% Compute Rayleigh BER values from simulations
timingIndex = 1;
for timing = timingRange(1):timingRange(3):timingRange(2)
    gammaIndex = 1;
    for gamma = gammaRangeRayleigh(1):gammaRangeRayleigh(3):gammaRangeRayleigh(2)
        if (ber(gammaIndex,timingIndex,1,2) > BER_LIMIT)
            % Use the theoretical BER for a guess of the appropriate number of symbols
            numSymb = round(100/ber(gammaIndex,timingIndex,1,2))
            if (numSymb > NUM_SYMB_LIMIT)
               numIters = round(numSymb/NUM_SYMB_LIMIT);
               numSymb = NUM_SYMB_LIMIT;
            else
                numIters = 1;
                numSymb = NUM_SYMB_LIMIT;  % keeping this large to get accurate slow fading effects
            end
            ber(gammaIndex,timingIndex,2,2) = 0;
            for jj = 1:numIters
                for ii = 1:(numSymb/SLOW_FADE_NUM_SYMB_PER_ITER)
                    [tempBer,ser] = basicModDemod(gamma,1,1,SLOW_FADE_NUM_SYMB_PER_ITER,0,0,1,timingError);
                    ber(gammaIndex,timingIndex,2,2) = ber(gammaIndex,timingIndex,2,2) + tempBer;
                end
            end
            ber(gammaIndex,timingIndex,2,2) = ber(gammaIndex,timingIndex,2,2)/(numIters*(numSymb/SLOW_FADE_NUM_SYMB_PER_ITER));   
        end
        % Save data
		if (~isempty(saveFile))
            save(saveFile);
		end
       gammaIndex = gammaIndex + 1;
    end
    timingIndex = timingIndex + 1;
end  
end %0

% Save data
if (~isempty(saveFile))
    save(saveFile);
end

TimingErrorBerPlotter;

⌨️ 快捷键说明

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