| Communications Toolbox | ![]() |
If your data is partitioned into a series of vectors (that you process within a loop, for example), then you can invoke the equalize function multiple times, saving the equalizer's internal state information for use in a subsequent invocation. In particular, the final values of the WeightInputs and Weights properties in one equalization operation should be the initial values in the next equalization operation. This section gives an example, followed by more general procedures for equalizing within a loop.
The example below illustrates how to use equalize within a loop, varying the equalizer between iterations. Because the example is long, this discussion presents it in these steps:
If you want to equalize iteratively while potentially changing equalizers between iterations, then the procedure in Changing the Equalizer Between Iterations should help you generalize from this example to other cases.
Initializing Variables. The beginning of the example defines parameters and creates three equalizer objects:
An RLS equalizer object.
An LMS equalizer object.
A variable, eq_current, that points to the equalizer object to use in the current iteration of the loop. Initially, this points to the RLS equalizer object. After the second iteration of the loop, eq_current is redefined to point to the LMS equalizer object.
% 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(6, rls(0.99,0.1)); % Create an RLS equalizer object. eqrls.SigConst = sigconst; % Set signal constellation. eqrls.ResetBeforeFiltering = 0; % Maintain continuity between iterations. eqlms = lineareq(6, 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.
Simulating the System Using a Loop. The next portion of the example is a loop that
Generates a signal to transmit and selects a portion to use as a training sequence in the first iteration of the loop
Introduces channel distortion
Equalizes the distorted signal using the chosen equalizer for this iteration, retaining the final state and weights for later use
Plots the distorted and equalized signals, for comparison
Switches to an LMS equalizer between the second and third iterations
% Main loop
for jj = 1:4
msg = randint(500,1,M); % Random message
modmsg = qammod(msg,M); % Modulate using 8-QAM.
% Set up training sequence for first iteration.
if jj == 1
ltr = 200; trainsig = modmsg(1:ltr);
else
% Use decision-directed mode after first iteration.
ltr = 0; trainsig = [];
end
% 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
endThe example produces one scatter plot for each iteration, indicating the iteration number and the adaptive algorithm in the title. A sample plot is below. Your plot might look different because the example uses random numbers.

This section describes two procedures for equalizing within a loop. The first procedure uses the same equalizer in each iteration, while the second is useful if you want to change the equalizer between iterations.
Using the Same Equalizer in Each Iteration. The typical procedure for using equalize within a loop is as follows:
Before the loop starts, create the equalizer object that you want to use in the first iteration of the loop.
Set the equalizer object's ResetBeforeFiltering property to 0 to maintain continuity between successive invocations of equalize.
Inside the loop, invoke equalize using a syntax like one of these:
y = equalize(eqz,x,trainsig); y = equalize(eqz,x);
The equalize function updates the state and weights of the equalizer at the end of the current iteration. In the next iteration, the function continues from where it finished in the previous iteration because ResetBeforeFiltering is set to 0.
This procedure is similar to the one used in Example: Equalizing Multiple Times, Varying the Mode. That example uses equalize multiple times but not within a loop.
Changing the Equalizer Between Iterations. In some applications, you might want to modify the adaptive algorithm between iterations. For example, you might use a CMA equalizer for the first iteration and an LMS or RLS equalizer in subsequent iterations. The procedure below gives one way to accomplish this, roughly following the example in Example: Adaptive Equalization Within a Loop:
Before the loop starts, create the different kinds of equalizer objects that you want to use during various iterations of the loop.
For example, create one CMA equalizer object, eqcma, and one LMS equalizer object, eqlms.
For each equalizer object, set the ResetBeforeFiltering property to 0 to maintain continuity between successive invocations of equalize.
Create a variable eq_current that points to the equalizer object that you want to use for the first iteration. Use = to establish the connection so that the two objects get updated together, as below.
eq_current = eqcma; % Point to eqcma.
The purpose of eq_current is to represent the equalizer used in each iteration, where you can switch equalizers from one iteration to the next by using a command like eq_current = eqlms. The example illustrates this approach near the end of its loop.
Inside the loop, perform these steps:
Invoke equalize using a syntax like one of these:
y = equalize(eq_current,x,trainsig); y = equalize(eq_current,x);
Copy the values of the WeightInputs and Weights properties from eq_current to the equalizer object that you want to use for the next iteration. Use dot notation. For example,
eqlms.WeightInputs = eq_current.WeightInputs; eqlms.Weights = eq_current.Weights;
Redefine eq_current to point to the equalizer object that you want to use for the next iteration, using =. Now eq_current is set up for the next iteration, because it represents the new kind of equalizer but retains the old values for the state and weights.
The reason for creating multiple equalizer objects and then copying the state and weights, instead of simply changing the equalizer class or adaptive algorithm in a single equalizer object, is that the class and adaptive algorithm properties of an equalizer object are fixed.
| Delays from Equalization | Using MLSE Equalizers | ![]() |
© 1994-2005 The MathWorks, Inc.