This is a static copy of a profile reportHome
int2str (11686 calls, 1.893 sec)
Generated 05-Nov-2014 07:52:34 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/matlab/strfun/int2str.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
num2str | function | 11686 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
32 | s = sprintf(['%', formatConver... | 11282 | 0.821 s | 43.4% |  |
31 | elseif isscalar(x) | 11686 | 0.230 s | 12.2% |  |
21 | widthCopy(~isfinite(widthCopy)... | 11686 | 0.170 s | 9.0% |  |
22 | formatConversion = '.0f'; | 11686 | 0.110 s | 5.8% |  |
18 | x = 0+round(x); %remove negati... | 11686 | 0.070 s | 3.7% |  |
All other lines | | | 0.491 s | 25.9% |  |
Totals | | | 1.893 s | 100% | |
Children (called functions)
No childrenCode Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 53 |
Non-code lines (comments, blank lines) | 23 |
Code lines (lines that can run) | 30 |
Code lines that did run | 23 |
Code lines that did not run | 7 |
Coverage (did run/can run) | 76.67 % |
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.06 11686 13 x = real(x);
14
15 % create a copy of x to use to calculate maximum width in digits
0.04 11686 16 widthCopy = x;
0.05 11686 17 if isfloat(x)
0.07 11686 18 x = 0+round(x); %remove negative zero
19 % replace Inf and NaN with a number of equivalent length for width
20 % calcultion
0.17 11686 21 widthCopy(~isfinite(widthCopy)) = 314;
0.11 11686 22 formatConversion = '.0f';
23 elseif isa(x, 'uint64')
24 formatConversion = 'lu';
25 else
26 formatConversion = 'ld';
27 end
28
0.06 11686 29 if isempty(x)
30 s = '';
0.23 11686 31 elseif isscalar(x)
0.82 11282 32 s = sprintf(['%', formatConversion], x);
0.01 404 33 else
34 % determine the variable text field width quantity
404 35 widthMax = double(max(abs(widthCopy(:))));
404 36 if widthMax == 0
37 width = 3;
404 38 else
404 39 width = floor(log10(widthMax)) + 3;
404 40 end
41
0.01 404 42 format = sprintf('%%%d%s', width, formatConversion);
43
404 44 [rows, cols] = size(x);
404 45 s = char(zeros(rows, width*cols));
404 46 for row = 1:rows
47 % use vectorized version of sprintf for each row
0.01 404 48 s(row,:) = sprintf(format, x(row,:));
404 49 end
50
51 % trim leading spaces from string array within constraints of rectangularity.
0.03 404 52 s = strtrim(s);
404 53 end
Other subfunctions in this file are not included in this listing.