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 = osfilter(ph,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.02, 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
plot([dn sens]);
Running the above script will produce the graph shown in Fig. 7.2. In this figure,
the sensor signal with and without control, and , respectively, are shown.
The sensor signal before applying the controller results from filtering the random
variable of zero mean and variance 1 through the primary path . The adaptive controller
adjusts its coefficients to produce a control signal to drive the secondary actuator that
results in reducing the primary noise at the sensor.
|