This is a static copy of a profile report

Home

int2str (586 calls, 0.044 sec)
Generated 05-Aug-2011 13:00:40 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/strfun/int2str.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
num2strfunction546
graphics/private/namefunction40
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
32
s = sprintf(['%', formatConver...
5860.022 s50.0%
18
x = 0+round(x); %remove negati...
5860.011 s25.0%
13
x = real(x);
5860.011 s25.0%
31
elseif isscalar(x)
5860 s0%
29
if isempty(x)
5860 s0%
All other lines  0 s0%
Totals  0.044 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function53
Non-code lines (comments, blank lines)23
Code lines (lines that can run)30
Code lines that did run9
Code lines that did not run21
Coverage (did run/can run)30.00 %
Function listing
   time   calls  line
1 function s = int2str(x)
2 %INT2STR Convert integer to string.
3 % S = INT2STR(X) rounds the elements of the matrix X to integers and
4 % converts the result into a string matrix.
5 % Return NaN and Inf elements as strings 'NaN' and 'Inf', respectively.
6 %
7 % See also NUM2STR, SPRINTF, FPRINTF, MAT2STR.
8
9 % Copyright 1984-2010 The MathWorks, Inc.
10 % $Revision: 5.20.4.11 $ $Date: 2010/11/22 02:46:49 $
11
12 % only work with real portion of x
0.01 586 13 x = real(x);
14
15 % create a copy of x to use to calculate maximum width in digits
586 16 widthCopy = x;
586 17 if isfloat(x)
0.01 586 18 x = 0+round(x); %remove negative zero
19 % replace Inf and NaN with a number of equivalent length for width
20 % calcultion
586 21 widthCopy(~isfinite(widthCopy)) = 314;
586 22 formatConversion = '.0f';
23 elseif isa(x, 'uint64')
24 formatConversion = 'lu';
25 else
26 formatConversion = 'ld';
27 end
28
586 29 if isempty(x)
30 s = '';
586 31 elseif isscalar(x)
0.02 586 32 s = sprintf(['%', formatConversion], x);
33 else
34 % determine the variable text field width quantity
35 widthMax = double(max(abs(widthCopy(:))));
36 if widthMax == 0
37 width = 3;
38 else
39 width = floor(log10(widthMax)) + 3;
40 end
41
42 format = sprintf('%%%d%s', width, formatConversion);
43
44 [rows, cols] = size(x);
45 s = char(zeros(rows, width*cols));
46 for row = 1:rows
47 % use vectorized version of sprintf for each row
48 s(row,:) = sprintf(format, x(row,:));
49 end
50
51 % trim leading spaces from string array within constraints of rectangularity.
52 s = strtrim(s);
53 end

Other subfunctions in this file are not included in this listing.