Created
August 11, 2013 09:08
-
-
Save robince/6204101 to your computer and use it in GitHub Desktop.
numbase2dec.m : Optimised numerical base2dec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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