1function [w1]=optwmc(zWin,n,w,mcAdapt,mu,order,beta,y,mcWForce)
 2%check mcForce
 3 if ~isempty(mcWForce)
 4  w = mcWForce(:,:,n);      
 5% If mcAdapt specified columns requested only adapt  
 6 elseif isempty(mcAdapt)
 7        normvec = sum(zWin.^2);  % Norm of each column
 8        normvec(normvec<1e-10) = 1e-10;  % Ensure norm is nonzero
 9        normmat = ones(order,1)*normvec;  % Expand to matrix
10        w = beta*w + mu*y(n)*zWin ./ normmat;  % Tap update
11    else
12        amcInds = find(mcAdapt(n,:));
13        normvec = sum(zWin(:, amcInds).^2);  % Norm of each column
14        normvec(normvec<1e-10) = 1e-10;  % Ensure norm is nonzero
15        normmat = ones(order,1)*normvec; 
16        w(:,amcInds) = beta*w(:,amcInds) + ...
17            mu*y(n)*zWin(:,amcInds) ./ normmat;  % Tap update
18 end
19  w1=w;
20end