Sunteți pe pagina 1din 4

Program: 1

% Set up parameters. M = 16; % Alphabet size for modulation sigconst = qammod(0:M-1,M); % Signal constellation for 16-QAM chan = [1 0.45 0.3+0.2i]; % Channel coefficients % Set up equalizers. eqrls = lineareq(10, rls(.99,.3)); % Create an RLS equalizer object. eqrls.SigConst = sigconst; % Set signal constellation. eqrls.ResetBeforeFiltering = 0; % Maintain continuity between iterations. eqlms = lineareq(10, lms(0.003)); % Create an LMS equalizer object. eqlms.SigConst = sigconst; % Set signal constellation. eqlms.ResetBeforeFiltering = 0; % Maintain continuity between iterations. eq_current = eqrls; % Point to RLS for first iteration. % Main loop for jj = 1:1 msg = randi([0 M-1],500,1); % Random message modmsg = qammod(msg,M); % Modulate using 16-QAM. % Set up if jj == ltr = else % Use ltr = end training sequence for first iteration. 1 200; trainsig = modmsg(1:ltr); decision-directed mode after first iteration. 0; trainsig = [];

% Introduce channel distortion. filtmsg = filter(chan,1,modmsg); % Equalize the received signal. s = equalize(eq_current,filtmsg,trainsig); % Plot signals. h = scatterplot(filtmsg(ltr+1:end),1,0,'bx'); hold on; scatterplot(s(ltr+1:end),1,0,'g.',h); scatterplot(sigconst,1,0,'k*',h); legend('Received signal','Equalized signal','Signal constellation'); title(['Iteration #' num2str(jj) ' (' eq_current.AlgType ')']); hold off; % Switch from RLS to LMS after second iteration. if jj == 2 eqlms.WeightInputs = eq_current.WeightInputs; % Copy final inputs. eqlms.Weights = eq_current.Weights; % Copy final weights. eq_current = eqlms; % Make eq_current point to eqlms. end end

Program: 2
Simulation of BER for different equalizers by changing the parameters
% System Fs = nBits = maxErrs = maxBits = simulation parameters 1; % sampling frequency (notional) 1024; % number of BPSK symbols per vector 100; % target number of errors at each Eb/No 1e6; % maximum number of symbols at each Eb/No

% Modulated signal parameters M = 2; % order of modulation Rs = Fs; % symbol rate nSamp = Fs/Rs; % samples per symbol Rb = Rs * log2(M); % bit rate % Channel parameters chnl = [0.227 0.460 0.688 0.460 0.227]'; % channel impulse response %Here 5 filter tap has been used, this can be increased for better result. chnlLen EbNo BER = length(chnl); % channel length, in samples = 0:14; % in dB = zeros(size(EbNo)); % initialize values

% Create PSK modulator hMod = modem.pskmod(M); % Create a local random stream to be used by random number generators for % repeatability. hStream = RandStream('mt19937ar', 'Seed', 12364); %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ % Linear equalizer parameters nWts = 31; % number of weights algType1 = 'rls'; % RLS algorithm for first data block at each Eb/No forgetFactor = 0.99988; % parameter of RLS algorithm algType2 = 'lms'; % LMS algorithm for remaining data blocks stepSize = 0.00001; % parameter of LMS algorithm % DFE parameters - use same update algorithms as linear equalizer nFwdWts = 15; % number of feedforward weights nFbkWts = 15; % number of feedback weights %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$ % MLSE equalizer parameters tbLen = 30; % MLSE equalizer traceback length numStates = M^(chnlLen-1); % number of trellis states [mlseMetric, mlseStates, mlseInputs] = deal([]); const = get(hMod, 'Constellation'); % signal constellation mlseType = 'ideal'; % perfect channel estimates at first

mlseMode % Channel chnlEst = prefixLen excessEst

= 'cont';

% no MLSE resets

estimation parameters chnl; % perfect estimation initially = 2*chnlLen; % cyclic prefix length = 1; % length of estimated channel impulse response % beyond the true length

% Initialize the graphics for the simulation. Plot the unequalized channel % frequency response, and the BER of an ideal BPSK system. idealBER = berawgn(EbNo, 'psk', M, 'nondiff'); [hBER, hLegend, legendString, hLinSpec, hDfeSpec, hErrs, hText1, hText2,... hFit, hEstPlot, hFig, hLinFig, hDfeFig] = eqber_graphics('init', chnl, ... EbNo, idealBER, nBits);

%The parameter which can be changed during simulation are as follows % (1) the channel impulse response, % (2) the number of equalizer tap weights, % (3) the recursive least squares (RLS) forgetting factor, % (4) the least mean square (LMS) step size, % (5) the MLSE traceback length, % (6) the error in estimated channel length, and % (7) the maximum number of errors collected at each Eb/No value.
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ alg1 = eval([algType1 '(' num2str(forgetFactor) ')']); linEq1 = lineareq(nWts, alg1); alg2 = eval([algType2 '(' num2str(stepSize) ')']); linEq2 = lineareq(nWts, alg2); [linEq1.RefTap, linEq2.RefTap] = ... deal(round(nWts/2)); % Set reference tap to center tap [linEq1.ResetBeforeFiltering, linEq2.ResetBeforeFiltering] = ... deal(0); % Maintain continuity between iterations dfeEq1 = dfe(nFwdWts, nFbkWts, alg1); dfeEq2 = dfe(nFwdWts, nFbkWts, alg2); [dfeEq1.RefTap, dfeEq2.RefTap] = ... deal(round(nFwdWts/2)); % Set reference tap to center forward tap [dfeEq1.ResetBeforeFiltering, dfeEq2.ResetBeforeFiltering] = ... deal(0); % Maintain continuity between iterations %The DFE error performance is burstier with detected bits fed back than with %correct bits fed back. %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ firstRun = true; % flag to ensure known initial states for noise and data eqType = 'linear'; eqber_adaptive;

%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ %Going bad close(hFig(ishghandle(hFig))); eqType = 'dfe'; eqber_adaptive; %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ close(hLinFig(ishghandle(hLinFig)), hDfeFig(ishghandle(hDfeFig))); eqType = 'mlse'; mlseType = 'ideal'; eqber_mlse; %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$ mlseType = 'imperfect'; eqber_mlse;

S-ar putea să vă placă și