Created
August 11, 2013 09:07
Revisions
-
robince created this gist
Aug 11, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ function x = numdec2base(d,b,m) %NUMDEC2BASE Convert decimal univariate integer to base B multivariate vector. % NUMDEC2BASE(D,B,M) returns the representation of D as a length-M base-B % word. % % Examples % numdec2base(23,3) returns [2;1;2] % numdec2base(23,3,5) returns [0;0;2;1;2] % % See also NUMBASE2DEC [m_in, Nt] = size(d); if m_in ~= 1 error('NUMDEC2BASE: input must be row vector') end z = b.^( (m-1):-1:0 ); x = floor(bsxfun(@rdivide, bsxfun(@rem,d,b*z'), z'));