📄 eqber_mlse.html
字号:
<html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document. --> <title>EQBER_MLSE - Simulation of MLSE equalizers with and without perfect channel knowledge</title> <meta name="generator" content="MATLAB 7.0"> <meta name="date" content="2004-06-23"> <meta name="m-file" content="eqber_mlse"><style>body { background-color: white; margin:10px;}h1 { color: #990000; font-size: x-large;}h2 { color: #990000; font-size: medium;}p.footer { text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;}pre.codeinput { margin-left: 30px;}span.keyword {color: #0000FF}span.comment {color: #228B22}span.string {color: #A020F0}span.untermstring {color: #B20000}span.syscmd {color: #B28C00}pre.showbuttons { margin-left: 30px; border: solid black 2px; padding: 4px; background: #EBEFF3;}pre.codeoutput { color: gray; font-style: italic;}pre.error { color: red;}/* Make the text shrink to fit narrow windows, but not stretch too far in wide windows. On Gecko-based browsers, the shrink-to-fit doesn't work. */ p,h1,h2,div { /* for MATLAB's browser */ width: 600px; /* for Mozilla, but the "width" tag overrides it anyway */ max-width: 600px; /* for IE */ width:expression(document.body.clientWidth > 620 ? "600px": "auto" );} </style></head> <body> <h1>EQBER_MLSE - Simulation of MLSE equalizers with and without perfect channel knowledge</h1> <p>This script runs a simulation loop for an MLSE equalizer with and without a perfect channel estimate. It also dynamically plots the spectrum estimate for the imperfect MLSE equalizer. It also plots the burst error performance of the MLSE equalizers. It also generates and plots BER results over a range of Eb/No values, and fits a curve to the simulated BER points. </p> <p>The channel estimation technique uses a cyclic prefix prepended to the transmitted data. The resulting augmented sequence is then looks periodic to an FFT, and such techniques can be used to accurately estimate the spectrum. Specifically, the FFT of the noisy, channel-filtered signal is divided by the FFT of the transmitted signal to give a noisy estimate of the channel frequency response. Although this technique is not ideal, and is highly dependent on the spectral characteristics of the data, it is a straightforward implementation of classic linear system theory. </p> <p>This script uses another script, <a href="eqber_siggen.html">eqber_siggen</a> to generate a noisy, channel-filtered signal. </p><pre class="codeinput">firstEstPlot = true; <span class="comment">% for channel estimate plot</span>firstErrPlot = true; <span class="comment">% for burst error plot - reset for imperfect MLSE</span><span class="comment">% Main simulation loop</span><span class="keyword">for</span> EbNoIdx = 1 : length(EbNo) <span class="comment">% Initialize channel and error collection parameters</span> chanState = []; numErrs = 0; numBits = 0; <span class="comment">% Reset the equalizer initial data</span> [mlseMetric, mlseStates, mlseInputs] = deal([]); <span class="comment">% Preallocate a buffer for the MLSE</span> lastMsg = zeros(tbLen, 1); firstBlk = true; <span class="comment">% counter for processing multiple data blocks</span> <span class="keyword">while</span> (numErrs < maxErrs && numBits < maxBits) eqber_siggen; <span class="comment">% generate a noisy, channel-filtered signal</span> <span class="keyword">if</span> (strcmp(mlseType,<span class="string">'imperfect'</span>)) <span class="comment">% Set an initial channel estimate.</span> chnlEst = [chnl; zeros(excessEst,1)]; <span class="comment">% Perform a channel estimate. Prepend a cyclic prefix to the</span> <span class="comment">% transmitted signal, then run it through the noisy channel and</span> <span class="comment">% truncate it to the estimated length. The estimated frequency</span> <span class="comment">% response is the FFT of the noisy signal divided by the FFT of the</span> <span class="comment">% transmitted signal.</span> augTx = [txSig(end-prefixLen+1:end); txSig]; <span class="comment">% create cyclic prefix</span> augFilt = filter(chnl, 1, augTx); augFilt = awgn(augFilt, SNR, <span class="string">'measured'</span>); augFilt = augFilt(prefixLen+1:end); HEstNum = fft(augFilt); HEstDen = fft(txSig); <span class="comment">% Test to avoid dividing by zero. If the test passes, perform the</span> <span class="comment">% division to generate the channel estimate.</span> <span class="keyword">if</span> (all(abs(real(HEstDen))>eps) && all(abs(imag(HEstDen))>eps)) HEst = HEstNum ./ HEstDen; chnlEst = ifft(HEst); chnlEst = chnlEst(1:chnlLen+excessEst); <span class="comment">% truncation w/error</span> <span class="keyword">end</span> <span class="comment">% Plot the spectrum of the channel estimate</span> hEstPlot = eqber_graphics(<span class="string">'chnlest'</span>, chnlEst, chnlLen, <span class="keyword">...</span> excessEst, nBits, firstEstPlot, hEstPlot); firstEstPlot = false; <span class="keyword">end</span> <span class="keyword">if</span> (numErrs < maxErrs) <span class="comment">% Equalize the signal with an MLSE equalizer and initialize the</span> <span class="comment">% equalizer states for the next block of data.</span> [eqSig, mlseMetric mlseStates mlseInputs] = <span class="keyword">...</span> mlseeq(noisySig, chnlEst, const, tbLen, mlseMode, nSamp, <span class="keyword">...</span> mlseMetric, mlseStates, mlseInputs); <span class="comment">% Demodulate the signal</span> demodSig = (1-sign(real(eqSig)))/2; <span class="comment">% Update the error statistics. Account for the delay in the</span> <span class="comment">% first block of processed data.</span> currMsg = msg(1:end-tbLen); fullMsg = [lastMsg; currMsg]; [currErrs, ratio] = biterr(fullMsg, demodSig); numErrs = numErrs + currErrs; <span class="keyword">if</span> (firstBlk) numBits = numBits + nBits - tbLen; <span class="keyword">else</span> numBits = numBits + nBits; <span class="keyword">end</span> BER(EbNoIdx) = numErrs / numBits; <span class="comment">% Retain the end of the current message for the next block of</span> <span class="comment">% data</span> lastMsg = msg(end-tbLen+1 : end); <span class="comment">% Plot the error vector for this frame of data</span> [hErrs, hText1, hText2] = eqber_graphics(<span class="string">'bursterrors'</span>, eqType, <span class="keyword">...</span> mlseType, firstErrPlot, fullMsg, demodSig, nBits, hErrs, <span class="keyword">...</span> hText1, hText2); firstErrPlot = false; <span class="keyword">end</span> <span class="comment">% Update the BER plot</span> [hBER, hLegend, legendString] = eqber_graphics(<span class="string">'simber'</span>, eqType, <span class="keyword">...</span> mlseType, firstBlk, EbNoIdx, EbNo, BER, hBER, hLegend, <span class="keyword">...</span> legendString); firstBlk = false; <span class="comment">% done processing first data block</span> <span class="keyword">end</span> <span class="comment">% end of simulation while loop</span> <span class="comment">% Fit a plot to the new BER points</span> hFit = eqber_graphics(<span class="string">'fitber'</span>, eqType, mlseType, hFit, EbNoIdx, EbNo, BER);<span class="keyword">end</span> <span class="comment">% end of 'for EbNoIdx' loop</span></pre><p class="footer">Copyright 1996-2004 The MathWorks, Inc.<br> Published with MATLAB® 7.0<br></p> <!--##### SOURCE BEGIN #####%% EQBER_MLSE - Simulation of MLSE equalizers with and without perfect channel knowledge% This script runs a simulation loop for an MLSE equalizer with and without a% perfect channel estimate. It also dynamically plots the spectrum estimate for% the imperfect MLSE equalizer. It also plots the burst error performance of% the MLSE equalizers. It also generates and plots BER results over a range of% Eb/No values, and fits a curve to the simulated BER points.%% The channel estimation technique uses a cyclic prefix prepended to the% transmitted data. The resulting augmented sequence is then looks periodic to% an FFT, and such techniques can be used to accurately estimate the spectrum.% Specifically, the FFT of the noisy, channel-filtered signal is divided by the% FFT of the transmitted signal to give a noisy estimate of the channel% frequency response. Although this technique is not ideal, and is highly% dependent on the spectral characteristics of the data, it is a straightforward% implementation of classic linear system theory.%% This script uses another script, <eqber_siggen.html eqber_siggen> to% generate a noisy, channel-filtered signal.% Copyright 1996-2004 The MathWorks, Inc.% $Revision: 1.1.4.1 $ $Date: 2004/06/30 23:03:14 $firstEstPlot = true; % for channel estimate plotfirstErrPlot = true; % for burst error plot - reset for imperfect MLSE% Main simulation loopfor EbNoIdx = 1 : length(EbNo) % Initialize channel and error collection parameters chanState = []; numErrs = 0; numBits = 0; % Reset the equalizer initial data [mlseMetric, mlseStates, mlseInputs] = deal([]); % Preallocate a buffer for the MLSE lastMsg = zeros(tbLen, 1); firstBlk = true; % counter for processing multiple data blocks while (numErrs < maxErrs && numBits < maxBits) eqber_siggen; % generate a noisy, channel-filtered signal if (strcmp(mlseType,'imperfect')) % Set an initial channel estimate. chnlEst = [chnl; zeros(excessEst,1)]; % Perform a channel estimate. Prepend a cyclic prefix to the % transmitted signal, then run it through the noisy channel and % truncate it to the estimated length. The estimated frequency % response is the FFT of the noisy signal divided by the FFT of the % transmitted signal. augTx = [txSig(end-prefixLen+1:end); txSig]; % create cyclic prefix augFilt = filter(chnl, 1, augTx); augFilt = awgn(augFilt, SNR, 'measured'); augFilt = augFilt(prefixLen+1:end); HEstNum = fft(augFilt); HEstDen = fft(txSig); % Test to avoid dividing by zero. If the test passes, perform the % division to generate the channel estimate. if (all(abs(real(HEstDen))>eps) && all(abs(imag(HEstDen))>eps)) HEst = HEstNum ./ HEstDen; chnlEst = ifft(HEst); chnlEst = chnlEst(1:chnlLen+excessEst); % truncation w/error end % Plot the spectrum of the channel estimate hEstPlot = eqber_graphics('chnlest', chnlEst, chnlLen, ... excessEst, nBits, firstEstPlot, hEstPlot); firstEstPlot = false; end if (numErrs < maxErrs) % Equalize the signal with an MLSE equalizer and initialize the % equalizer states for the next block of data. [eqSig, mlseMetric mlseStates mlseInputs] = ... mlseeq(noisySig, chnlEst, const, tbLen, mlseMode, nSamp, ... mlseMetric, mlseStates, mlseInputs); % Demodulate the signal demodSig = (1-sign(real(eqSig)))/2; % Update the error statistics. Account for the delay in the % first block of processed data. currMsg = msg(1:end-tbLen); fullMsg = [lastMsg; currMsg]; [currErrs, ratio] = biterr(fullMsg, demodSig); numErrs = numErrs + currErrs; if (firstBlk) numBits = numBits + nBits - tbLen; else numBits = numBits + nBits; end BER(EbNoIdx) = numErrs / numBits; % Retain the end of the current message for the next block of % data lastMsg = msg(end-tbLen+1 : end); % Plot the error vector for this frame of data [hErrs, hText1, hText2] = eqber_graphics('bursterrors', eqType, ... mlseType, firstErrPlot, fullMsg, demodSig, nBits, hErrs, ... hText1, hText2); firstErrPlot = false; end % Update the BER plot [hBER, hLegend, legendString] = eqber_graphics('simber', eqType, ... mlseType, firstBlk, EbNoIdx, EbNo, BER, hBER, hLegend, ... legendString); firstBlk = false; % done processing first data block end % end of simulation while loop % Fit a plot to the new BER points hFit = eqber_graphics('fitber', eqType, mlseType, hFit, EbNoIdx, EbNo, BER); end % end of 'for EbNoIdx' loop##### SOURCE END #####--> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -