This is a static copy of a profile report

Home

dec2hex (1 call, 0.000 sec)
Generated 05-Nov-2014 07:52:56 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/matlab/strfun/dec2hex.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
genvarnamefunction1
Lines where the most time was spent
No measurable time spent in this function

Line NumberCodeCallsTotal Time% TimeTime Plot
58
h = reshape(h,n0,numD)';
10 s0%
49
h = sprintf('%0*X',[n,d]');
10 s0%
48
if all(d<bits32),
10 s0%
43
if numD>1
10 s0%
41
n0 = n;
10 s0%
All other lines  0 s0%
Totals  0 s0% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function58
Non-code lines (comments, blank lines)28
Code lines (lines that can run)30
Code lines that did run14
Code lines that did not run16
Coverage (did run/can run)46.67 %
Function listing
   time   calls  line
1 function h = dec2hex(d,n)
2 %DEC2HEX Convert decimal integer to hexadecimal string.
3 % DEC2HEX(D) returns a 2-D string array where each row is the
4 % hexadecimal representation of each decimal integer in D.
5 % D must contain non-negative integers smaller than 2^52.
6 %
7 % DEC2HEX(D,N) produces a 2-D string array where each
8 % row contains an N digit hexadecimal number.
9 %
10 % Example
11 % dec2hex(2748) returns 'ABC'.
12 %
13 % See also HEX2DEC, HEX2NUM, DEC2BIN, DEC2BASE.
14
15 % Copyright 1984-2010 The MathWorks, Inc.
16 % $Revision: 5.15.4.11 $ $Date: 2011/02/15 00:54:09 $
17
1 18 bits32 = 4294967296; % 2^32
19
1 20 if nargin<1
21 error(nargchk(1,2,nargin,'struct'));
22 end
23
1 24 d = d(:); % Make sure d is a column vector.
25
1 26 if ~isreal(d) || any(d < 0) || any(d ~= fix(d))
27 error(message('MATLAB:dec2hex:FirstArgIsInvalid'))
28 end
1 29 if any(d > 1/eps)
30 warning(message('MATLAB:dec2hex:TooLargeArg'));
31 end
32
1 33 numD = numel(d);
34
1 35 if nargin==1,
36 n = 1; % Need at least one digit even for 0.
37 end
38
1 39 [f,e] = log2(double(max(d)));%#ok
1 40 n = max(n,ceil(e/4));
1 41 n0 = n;
42
1 43 if numD>1
44 n = n*ones(numD,1);
45 end
46
47 %For small enough numbers, we can do this the fast way.
1 48 if all(d<bits32),
1 49 h = sprintf('%0*X',[n,d]');
50 else
51 %Division acts differently for integers
52 d = double(d);
53 d1 = floor(d/bits32);
54 d2 = rem(d,bits32);
55 h = sprintf('%0*X%08X',[n-8,d1,d2]');
56 end
57
1 58 h = reshape(h,n0,numD)';