| Purpose |
| Simulation of an adaptive forward modeling application using an recursive adaptive filter updated according to the Simple Hyperstable Adaptive Recursive Filter (SHARF) algorithm. |
| Syntax |
model_sharf
|
| Description |
The block diagram of the system identification (forward modeling) problem using the SHARF adaptive algorithm is shown in Fig. 10.53 (see Section 6.4 for more information on the SHARF algorithm). The simulation considered here uses a recursive filter for the adjustable filter and the coefficients of the filter are updated using the SHARF algorithm. The input signal init_sharf(), and the input signals are read from files, then a processing loop is started. In each iteration of the loop asptsharf() is called with a new input sample and a new desired sample to calculate the filter output (estimated desired signal) and update the filter coefficients.
This simulation script uses the standard ASPT iteration progress window (IPWIN). The
IPWIN has four buttons which allow you to stop and continue the simulation, show or
hide the simulation graph window, break out of the processing loop, and quit the
simulation. After processing all the samples, or on pressing the break or stop
buttons, the sensor signal
|
| Code |
clear all; infile = '.\wavin\scinwn.wav'; % input signal dfile = '.\wavin\scdar22.wav'; % desired signal N = 2; % number of zeros M = 2; % number of poles L = 5; % smoothing FIR length H = 50; % response length p1 = .2 + j* .85; % unknown filter poles p2 = .2 - j* .85; % for verification ip = [1; zeros(H-1,1)]; % impulse vector h = filter([0.6 -.01],[1 -(p1+p2) (p1*p2)],ip); % Initial parameters u = zeros(N+M,1); % composite input vector w = u; % initial filter vector c = filter(.01,[1 -.99],ip(1:L));% error smoothing filter e = randn(L,1); % initial error vector d = randn(1,1); % initial desired sample mu = [.01;0.01;.003;0.003] ; % Step size vector % Create and initialize EQERR IIR filter [u,w,e,c,d,mu,Px,Py] = init_sharf(N,M,L,u,w,e,c,d,mu); [xn,inFs,inBits] = wavread(infile); % read input [dn,inFs,dBits] = wavread(dfile); % read desired inSize = max(length(dn),length(xn)); % samples to process E = init_ipwin(inSize); % Initialize IPWIN %% Processing Loop for (m=1:inSize) x = 2^(inBits-1) * xn(m); % input sample d = 2^(inBits-1) * dn(m); % desired sample % update the adaptive coefficients [w,u,y,e,Px,Py]=asptsharf(N,M,w,u,x,d,e,c,mu,Px,Py); % impulse response for verification wp = filter(w(1:N),[1 ; -w(N+1:N+M)],ip); % update the iteration progress window [E, stop,brk] = update_ipwin(E,e(1),d, 'm', wp, h); % handle the Stop button while (stop ~= 0), stop = getStop; end; % handle the Break button if (brk), plot_model(wp,h,E); break; end; end; plot_model(wp,h,E); |
| Results |
Running the above script will produce the graph shown in Fig. 10.54. The two top-left panels in Fig. 10.54 show the time and frequency responses of the unknown system for which this application is intended to provide an IIR model. The time and frequency responses for the model obtained by the adaptive filter are shown in the two top-right panels. The bottom-left panel shows the learning curve and the bottom-right panel shows the estimation error in the impulse response.
|
| See Also |
| INIT_ SHARF, ASPTSHARF. |
| Reference |
| [2] and [10] for introduction to recursive adaptive filters. |