This is a static copy of a profile report

Home

int2str (477 calls, 0.111 sec)
Generated 14-Nov-2016 07:47:08 using cpu time.
function in file /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/strfun/int2str.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
num2strfunction471
graphics/private/namefunction6
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
41
format = sprintf('%%%d%s', wid...
1340.020 s18.2%
31
s = sprintf(['%', formatConver...
3430.020 s18.2%
44
s = char(zeros(rows, width*col...
1340.010 s9.1%
30
elseif isscalar(x)
4770.010 s9.1%
21
formatConversion = '.0f';
4770.010 s9.1%
All other lines  0.040 s36.4%
Totals  0.111 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function52
Non-code lines (comments, blank lines)22
Code lines (lines that can run)30
Code lines that did run23
Code lines that did not run7
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 

  11 
% only work with real portion of x
  0.01 
    477 
  12 
x = real(x); 
  13 

  14 
% create a copy of x to use to calculate maximum width in digits
    477 
  15 
widthCopy = x; 
    477 
  16 
if isfloat(x) 
  0.01 
    477 
  17 
    x = 0+round(x); %remove negative zero 
  18 
    % replace Inf and NaN with a number of equivalent length for width
  19 
    % calcultion
  0.01 
    477 
  20 
    widthCopy(~isfinite(widthCopy)) = 314; 
  0.01 
    477 
  21 
    formatConversion = '.0f'; 
  22 
elseif isa(x, 'uint64')
  23 
    formatConversion = 'lu';
  24 
else
  25 
    formatConversion = 'ld';
  26 
end
  27 

    477 
  28 
if isempty(x) 
  29 
    s = '';
  0.01 
    477 
  30 
elseif isscalar(x) 
  0.02 
    343 
  31 
    s = sprintf(['%', formatConversion], x); 
    134 
  32 
else 
  33 
    % determine the variable text field width quantity
    134 
  34 
    widthMax = double(max(abs(widthCopy(:)))); 
    134 
  35 
    if widthMax == 0 
  36 
        width = 3;
    134 
  37 
    else 
    134 
  38 
        width = floor(log10(widthMax)) + 3; 
    134 
  39 
    end 
  40 

  0.02 
    134 
  41 
    format = sprintf('%%%d%s', width, formatConversion); 
  42 

    134 
  43 
    [rows, cols] = size(x); 
  0.01 
    134 
  44 
    s = char(zeros(rows, width*cols)); 
    134 
  45 
    for row = 1:rows 
  46 
        % use vectorized version of sprintf for each row
    134 
  47 
        s(row,:) = sprintf(format, x(row,:)); 
    134 
  48 
    end 
  49 

  50 
    % trim leading spaces from string array within constraints of rectangularity.
    134 
  51 
    s = strtrim(s); 
    134 
  52 
end 

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