function i = bin_to_dec(x)
%Translates a binary vector to its 
%decimal equivalent.
%NB= integer, number of bits
%x= NB component row vector; 
%   binary representation of i, prepadded with zeros so it has NB bits
%i= integer between 0 and 2^NB-1
NB=length(x);
if (NB<1)
	error("NB is less than 1");
end
i=0;
for alp=0:(NB-1)
	i =  i + 2^alp*x(NB - alp);
end