The MATLAB code below is for equalizer using lms algorithm adaptive filter and then plotting MSE (Mean Square Error) Vs Iteration numbers
%% Channel Equalization using Least Mean Square (LMS) algorithm % Author: SHUJAAT KHAN clc;clear all;close all; %% Channel and noise level h = [0.9 0.3 0.5 -0.1]; % Channel SNRr = 10; % Noise Level %% Input/Output data N = 1000; % Number of samples Bits = 2; % Number of bits for modulation (2-bit for Binary modulation) data = randi([0 1],1,N); % Random signal d = real(qammod(data,Bits)); % BPSK Modulated signal (desired/output) r = filter(h,1,d); % Signal after passing through channel x = awgn(r, SNRr); % Noisy Signal after channel (given/input) %% LMS parameters epoch = 50; % Number of epochs (training repmiotion) mio = 1e-3; % Learning rate / step size order=12; % Order of the equalizer U = zeros(1,order); % Input frame W = zeros(1,order); % Initial Weigths %% LMS Algorithm for k = 1 : epoch for n = 1 : N U(1,2:end) = U(1,1:end-1); % Sliding window U(1,1) = x(n); % Present Input y = (W)*U'; % Calculating output of LMS e(n) = d(n) - y; % Instantaneous error W = W + mio * e(n) * U ; % Weight update rule of LMS J(k,n) = e(n) * e(n)'; % Instantaneous square error end end %% Calculation of performance parameters MJ = mean(J,2); % Mean square error %% Plots figure % MSE plot(10*log10(MJ),'linewidth',lw) hg=legend('MSE','Location','Best'); grid minor xlabel('Epochs iterations'); ylabel('Mean squared error (dB)'); title('Cost function');
But the curve plotted is unexpected, as the MSE should have fluctuations across iterations and to be very smooth like that as it LMS algorithm is used
That's because it doesn't take the Expectation in the adaptive equation.
The curve plotted is as the following:
Where the expected plot is as the following: