mai_fouad
Newbie level 1
I want to equalize 2x2 MIMO system, the system uses two optical fiber as a communication channel, the fiber length divided into segments and at the end of each segment coupling between two fibers occurs that needed to be equalized using LMS algorithm
I use this code and want to check is it the correct 2x2 LMS equalizer or not as it couldn't compensate the effect of the channel:
I use this code and want to check is it the correct 2x2 LMS equalizer or not as it couldn't compensate the effect of the channel:
Code:
function [outputVector,...
errorVector,...
coefficientVector1,coefficientVector2] = LMS(desired,input1,input2,step,filter_length1,filter_length2,initial_coeff1,initial_coeff2)
% Some Variables and Definitions:
% . prefixedInput : Input is prefixed by nCoefficients -1 zeros.
% (The prefix led to a more regular source code)
%
% . regressor : Auxiliar variable. Store the piece of the
% prefixedInput that will be multiplied by the
% current set of coefficients.
% (regressor is a COLUMN vector)
%
% . nCoefficients : FIR filter number of coefficients.
%
% . nIterations : Number of iterations.
% Initialization Procedure
nCoefficients1 = filter_length1;
nCoefficients2 = filter_length2;
nIterations = length(desired);
% Pre Allocations
errorVector = zeros(nIterations ,1);
outputVector = zeros(nIterations ,1);
outputVector1 = zeros(nIterations ,1);
outputVector2 = zeros(nIterations ,1);
coefficientVector1 = zeros(nCoefficients1 ,(nIterations+1));
coefficientVector2 = zeros(nCoefficients2 ,(nIterations+1));
% Initial State Weight Vector
coefficientVector1(:,1) = initial_coeff1;
coefficientVector2(:,1) = initial_coeff2;
% Improve source code regularity
prefixedInput1 = [zeros(nCoefficients1-1,1)
transpose(input1)];
prefixedInput2 = [zeros(nCoefficients2-1,1)
transpose(input2)];
% Body
for it = 1:nIterations,
it;
regressor1 = prefixedInput1(it+(nCoefficients1-1):-1:it,1);
regressor2 = prefixedInput2(it+(nCoefficients2-1):-1:it,1);
outputVector1(it,1) = (coefficientVector1(:,it)')*regressor1;
outputVector2(it,1) = (coefficientVector2(:,it)')*regressor2;
outputVector(it,1) = outputVector1(it,1)+outputVector2(it,1);
errorVector(it,1) = desired(it)-outputVector(it,1);
coefficientVector1(:,it+1) = coefficientVector1(:,it)+...
(step*conj(errorVector(it,1))*...
regressor1);
coefficientVector2(:,it+1) = coefficientVector2(:,it)+...
(step*conj(errorVector(it,1))*...
regressor2);
end
Last edited by a moderator: