function u=BaseB2Decimal(s,b)
% BASEBDECIMAL convert a number from and arbitrary base to decimal
%   u=BaseB2Decimal(s,b) converts a string s which represents an
%   integer in base b to the decimal number u using Horner's rule.

n=length(s); u=0;
for i=1:n
  if char(s(i))<=57,        % Assume decimal digit
    a=s(i)-48;              % subtract ASCII number of zero
  else                      % Assume capital letter
    a=s(i)-55;              % subtract ASCII number 65 of A and add 10
  end
  u=u*b+a; 
end
