This is a static copy of a profile reportHome
int2str (18 calls, 0.000 sec)
Generated 15-Mar-2007 12:01:43 using real time.
M-function in file C:\Program Files\MATLAB71\toolbox\matlab\strfun\int2str.m
[Copy to new window for comparing multiple runs]
Parents (calling functions)
Lines where the most time was spent
No measurable time spent in this functionLine Number | Code | Calls | Total Time | % Time | Time Plot |
17 | s = s(1:length(s)-2); % remov... | 18 | 0 s | 0% |  |
16 | s = sprintf('%.1f',x); % .1 to... | 18 | 0 s | 0% |  |
15 | if isfinite(x) | 18 | 0 s | 0% |  |
13 | if length(x) == 1 | 18 | 0 s | 0% |  |
12 | x = round(real(x)); | 18 | 0 s | 0% |  |
Other lines & overhead | | | 0 s | 0% |  |
Totals | | | 0.000 s | 0% | |
Children (called functions)
No childrenM-Lint results
No M-Lint messages.Coverage results
[ Show coverage for parent directory ]
Total lines in file | 88 |
Non-code lines (comments, blank lines) | 24 |
Code lines (lines that can run) | 64 |
Code lines that did run | 5 |
Code lines that did not run | 59 |
Coverage (did run/can run) | 7.81 % |
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
4 % integers and 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-2004 The MathWorks, Inc.
10 % $Revision: 5.20.4.6 $ $Date: 2004/04/16 22:08:40 $
11
18 12 x = round(real(x));
18 13 if length(x) == 1
14 % handle special case of single infinite or NaN element
18 15 if isfinite(x)
18 16 s = sprintf('%.1f',x); % .1 to avoid precision loss on hpux
18 17 s = s(1:length(s)-2); % remove .d decimal digit
18 else
19 s = sprintf('%.0f',x);
20 end
21 else
22
23 t = '';
24 [m,n] = size(x);
25 % Determine elements of x that are finite.
26 xfinite = x(isfinite(x));
27 % determine the variable text field width quantity
28
29 xmax = double(max(abs(xfinite(:))));
30 if xmax == 0
31 d = 1;
32 else
33 d = floor(log10(xmax)) + 1;
34 end
35
36 clear('xfinite')
37 % delimit string array with one space between all-NaN or all-Inf columns
38 if any(isnan(x(:)))||any(isinf(x(:)))
39 d = max([d;3]);
40 end
41 % create cell arrays for storage
42 scell = cell(1,m);
43 empties = true(1,m);
44 % Have to make a special case for HP as it has different behavior for
45 % format '%*.0f'.
46 if(strcmpi(computer,'HPUX'))
47 HPUXFlag = true;
48 else
49 HPUXFlag = false;
50 end
51 % walk through numbers array and convert elements to strings
52 for i = 1:m
53 if HPUXFlag == false
54 % use vectorized version of sprintf
55 if n > 1
56 t = sprintf('%*.0f',[repmat((d+2),1,n);x(i,:)]);
57 else
58 t = sprintf('%*.0f',d+2,x(i,:));
59 end
60 else % special case for HPUX
61 t = '';
62 for j = 1:n
63 if isfinite(x(i,j))
64 p = sprintf('%*.1f',d+4,x(i,j)); % .1 to avoid precision loss on hpux
65 p = p(1:length(p)-2); % remove .d decimal digit
66 t = [t p];
67 else
68 t = [t sprintf('%*.0f',d+2,x(i,j))];
69 end
70 end
71 end
72 if ~isempty(t)
73 scell{i} = t;
74 empties(i) = false;
75 end
76 end
77 if m > 1
78 s = char(scell{~empties});
79 else
80 s = t;
81 end
82 % trim leading spaces from string array within constraints of rectangularity.
83 if ~isempty(s)
84 while all(s(:,1) == ' ')
85 s(:,1) = [];
86 end
87 end
88 end