iter = 5000; % Number of samples to process
ph = [0;.9;.5;.3;.1]; % Primary path impulse response
sh = [0.5;0.4;0.1]; % Secondary path impulse response
se = 0.95*sh; % estimation of s
xn = 2*(rand(iter,1)-0.5); % Input signal, zero mean random.
dn = filter(ph,1,xn); % Primary response at the sensor sens = zeros(iter,1); % vector to collect sensor signal
% Initialize ADJLMS algorithm with a controller of 10 coefficients
[w,x,y,d,e,p] = init_adjlms(10,sh,se);
%% Processing Loop
for (m=1:iter)
% update the input delay line
x = [xn(m,:); x(1:end-1,:)];
% call asptadjlms to calculate the controller output
% and update the coefficients. Below a step size of
% 0.02 and an AR pole of 0.98 are used.
[w,y,e,p] = asptadjlms(w,x,e,y,sh,se,dn(m),p, 0.05, 0.98);
% save the last calculated sensor sample for
%performance examination
sens(m) = e(1);
end;
% display the sensor signal before and after the control effort
subplot(2,1,1);
plot([dn sens]);