image thumbnail
from System Identification Comparison by Mayowa
Comparison of system identification using LMS, NLMS & LMF

sysidcomp.m
clear all
clc

nBits = 3000;           %Number of Bits
chan = [.3 .9 .3];      %Channel
L = 3;                  %Filter Length
plotcol = ['r' ; 'g' ; 'b'];
%number of iterations
nIters = 125;

%step sizes
mu_lms = 0.003; %LMS
mu_lmf = 0.3;   %LMF
mu_nlms = 0.03; %NLMS


%EbNo
LogEbNo = 20;

%MSE
MSE=zeros(nIters, nBits);		% prepare to accumulate MSE*I

w0 = zeros(L,1);                %initialise with zeros
N = L-1;
% --- Simulation Loops --- %

% --- The Channel --- %
EbNo = 10^(LogEbNo/10);
Eb = 1;
No = Eb/EbNo;

for eqtype = 1:3
    for iter = 1:nIters
        iter
        % --- Transmitter --- %
        TxSymbols = randsrc(nBits,1);
        x = TxSymbols;

        ChanReg = zeros(1, L);
        X = zeros(1, L);    % equalizer register

        w = w0;
        for k = 1:nBits
            ChanReg = [x(k) ChanReg(1:(end-1))];
            X = [x(k) X(1:(end-1))];
            DEN = X*X' + 0.000000001;
            d = ChanReg * chan' + rand*sqrt(No);
            e(k) = d- X*w;

            if eqtype == 1
                %LMS
                w = w + mu_lms*e(k)*X';
            elseif eqtype == 2
                %LMF
                w = w + mu_lmf*(e(k)^3)*X';
            else
                %NLMS
                w = w + mu_nlms*e(k)*X'/DEN;
            end
        end

        MSE(iter,:) = e.*e;
    end

    MSEdB = 10*log10(mean(MSE));

    plot(1:nBits, MSEdB,  plotcol(eqtype));
    hold on
end
legend('LMS', 'LMF', 'NLMS')
hold off

Contact us at files@mathworks.com