%DEMO of ADAPTIVE EQUALIZATION USING THE LMS ALGORITHM %------- Define equalizer parameters N = 4; % number of equalizer coefficients mu = 0.005; % equalizer step size %------- Define modulation parameters alphabet = [-3 -1 1 3]; K = 400; % number of symbols to transmit %------- Define channel parameters h = [1 -0.5]; % channel impulse response sig = 0.1; % noise standard deviation %------- Generate channel output r a = alphabet(ceil((length(alphabet)*rand(1,K)))); r = conv(a,h) + sig * randn(1, K + length(h)-1); %------------------------------------ C = zeros(N,1); R = zeros(N,1); for k=1:K, R(2:N) = R(1:N-1); R(1) = r(k); z(k) = C.' * R; e(k) = z(k) - a(k); % LMS C = C - mu * e(k) * conj(R); % algorithm Cs(k,:) = C'; end; subplot(211); plot(z,'o'); xlabel('Time (in symbol periods)'); ylabel('Equalizer output'); subplot(212); plot(Cs); xlabel('Time (in symbol periods)'); ylabel('Equalizer coefficients');