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

📄 c10_mcbpskrun.m

📁 北邮通信仿真教程第10章的源程序
💻 M
字号:
% File: c10_MCBPSKrun.m
%
%
function [BER,Errors]=MCBPSKrun(N,EbNo,delay,FilterSwitch)
SamplesPerSymbol = 10;   						% samples per symbol
BlockSize = 1000;								% block size              
NoiseSigma = sqrt(SamplesPerSymbol/(2*EbNo));   % scale noise level
DetectedSymbols = zeros(1,BlockSize);			% initialize vector           
NumberOfBlocks = floor(N/BlockSize);			% number of blocks processed      
[BTx,ATx] = butter(5,2/SamplesPerSymbol);  		% compute filter parameters
[TxOutput,TxFilterState] = filter(BTx,ATx,0);	% initialize state vector
BRx = ones(1,SamplesPerSymbol); ARx=1;          % matched filter parameters
Errors = 0;										% initialize error counter                
%                       
% Simulation loop begine here.
%
for Block=1:NumberOfBlocks           
     %
     % Generate transmitted symbols.
     %
     [SymbolSamples,TxSymbols] = random_binary(BlockSize,SamplesPerSymbol);
     %
     % Transmitter filter if desired.
     %
     if FilterSwitch==0
        TxOutput = SymbolSamples;
     else   
        [TxOutput,TxFilterState] = filter(BTx,ATx,SymbolSamples,TxFilterState);
     end
     %
     % Generate channel noise.
     %
     NoiseSamples = NoiseSigma*randn(size(TxOutput));
     %
     % Add signal and noise.
     %
     RxInput = TxOutput + NoiseSamples; 
     %
     % Pass Received signal through matched filter.
     %
     IntegratorOutput = filter(BRx,ARx,RxInput);
     %
     % Sample matched filter output every SamplesPerSymbol samples,
     % compare to transmitted bit, and count errors.
     %
     for k=1:BlockSize,
        m = k*SamplesPerSymbol+delay;
        if (m < length(IntegratorOutput))
           DetectedSymbols(k) = (1-sign(IntegratorOutput(m)))/2;
           if (DetectedSymbols(k) ~= TxSymbols(k))
              Errors = Errors + 1;
           end
        end
     end   
end                            
BER = Errors/(BlockSize*NumberOfBlocks); 	% calculate BER
% End of function file.

⌨️ 快捷键说明

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