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 the sensor signal
% Initialize Filtered-x algorithm with a controller of 10 coef.
[w,x,y,d,e,p,fx] = init_fxlms(10,sh,se);
%% Processing Loop
for (m=1:iter)
% update the input delay line
x = [xn(m,:); x(1:end-1,:)];
% call asptfxlms 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,fx] = asptfxlms(w,x,y,sh,se,dn(m),fx,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
% applying the controller
subplot(2,1,1);
plot([dn sens]);