matlab base2dec,dec2base.m 源代码在线查看 - matlab6.5 资源下载 虫虫电子下载站
function s = dec2base(d,b,nin)%DEC2BASE Convert decimal integer to base B string.%DEC2BASE(D,B) returns the representation of D as a string in%base B.D must be a non-negative integer smaller t...
function s = dec2base(d,b,nin)%DEC2BASE Convert decimal integer to base B string.% DEC2BASE(D,B) returns the representation of D as a string in% base B. D must be a non-negative integer smaller than 2^52% and B must be an integer between 2 and 36.%% DEC2BASE(D,B,N) produces a representation with at least N digits.%% Examples% dec2base(23,3) returns '212'% dec2base(23,3,5) returns '00212'%% See also BASE2DEC, DEC2HEX, DEC2BIN.% Copyright 1984-2002 The MathWorks, Inc. % $Revision: 1.13 $ $Date: 2002/04/09 00:33:33 $% Original by Douglas M. Schwarz, Eastman Kodak Company, 1996.d = d(:);if d ~= floor(d) | any(d < 0) | any(d > 1/eps) error('D must be an integer, 0 endif b ~= floor(b) | b < 2 | b > 36 error('B must be an integer, 2 endn = max(1,round(log2(max(d)+1)/log2(b)));while any(b.^n n = n + 1;endif nargin == 3 n = max(n,nin);ends(:,n) = rem(d,b);while n > 1 & any(d) n = n - 1; d = floor(d/b); s(:,n) = rem(d,b);endsymbols = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';s = reshape(symbols(s + 1),size(s));
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)