
% A helper function to remove (set to zero) 
% n bits from the least significant portion of each
% entry in a matrix
% 
% It uses the bitset function to achieve this
%
% Haircut - the matrix with the LSB bits "shaved" off
% X - the source matrix
% n - the number of bits to set to 0
function Haircut = removelsb(X, n)

s = size(X);
Haircut = double(X);

for k = 1:n
    Haircut = bitset(Haircut, k, 0);
end
Haircut = uint8(Haircut);
