Skip to content

Instantly share code, notes, and snippets.

@robince
Created August 11, 2013 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robince/6204101 to your computer and use it in GitHub Desktop.
Save robince/6204101 to your computer and use it in GitHub Desktop.
numbase2dec.m : Optimised numerical base2dec
function d = numbase2dec(x,b)
%NUMBASE2DEC Convert base B numerical multivariate array to decimal integer.
% NUMBASE2DEC(x,B) converts the multivarate array of base B into its
% univariate decimal (base 10) equivalent.
%
% X should be M x Nt representing Nt different length-M base B words.
%
% Example
% numbase2dec([2; 1; 2],3) returns 23
%
% See also NUMDEC2BASE
[m, Nt] = size(x);
z = b.^( (m-1):-1:0 );
d = z*x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment