1function [bWin,zn,w1]=targbm(bp,b,x,n,order,w,z)
 2
 3% Select the data window (column vector) and ouput adapf  
 4if n <= order  % feed in supplied past values ahead of b
 5        bWin = [bp(end-order+n+1:end); b(1:n)];
 6else  % need only data from given b
 7        bWin = b(n-order+1:n,:);
 8end
 9     
10% initial w ,and calculate output y      
11
12 z(n,:)= x(n,:) - (w'*bWin)';  % Subtract filtered b
13
14% check y inf or not
15 if any(~isfinite(z(n,:))), error('Output has blown up'), end
16 w1=w;
17zn=z;
18end