function z = base2(nvec)
%
% Converts each element of the row vector nvec into a binary
% vector that forms the columns of the output

base = 2*ones(1,length(nvec));

z = [];
k = 0;
a = fix(nvec./(base.^k));
while max(a)>0
 z(k+1,:) = rem(a,base);
 k = k+1;
 a = fix(nvec./(base.^k));
end

