I am trying to save the value of en from this Least Mean Square algorithm after each loop, but my attempt at it does not seem to be working. How can I fix this?
close;clear;clc;load sig.mat; % loads variables x and y
N = 5; % filter length
u = .01; % learning rate
h = zeros(1, N);hold = zeros(1,500);for n = 1:500 if n-N < 1 xn = [x(n:-1:1); zeros(N-n, 1)]; else xn = x(n:-1:n-N+1); end en = y(n) - h*xn; hold = en; % Why is this not saving en after each iteration?
h = h + (u*en*xn)';end
Best Answer