function [bWin,yn,w1]=targbm(bp,b,x,n,order,w,y)
% Select the data window (column vector) and ouput adapf
if n <= order % feed in supplied past values ahead of b
bWin = [bp(end-order+n+1:end); b(1:n)];
else % need only data from given b
bWin = b(n-order+1:n,:);
end
% initial w ,and calculate output y
y(n,:)= x(n,:) – (w’*bWin)’; % Subtract filtered b
% check y inf or not
if any(~isfinite(y(n,:))), error(‘Output has blown up’), end
w1=w;
yn=y;
end