This is a static copy of a profile report

Home

int2str (Calls: 7, Time: 0.002 sec)
Generated 28-May-2016 14:58:48 using performance time.
function in file /home/johs/MATLAB/R2015b/toolbox/matlab/strfun/int2str.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
num2strfunction7
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
31
s = sprintf(['%', formatConver...
70.001 s28.5%
20
widthCopy(~isfinite(widthCopy)...
70.000 s15.1%
16
if isfloat(x)
70.000 s12.4%
30
elseif isscalar(x)
70.000 s9.4%
28
if isempty(x)
70.000 s0.1%
All other lines  0.001 s34.6%
Totals  0.002 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 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 

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

  14 
% create a copy of x to use to calculate maximum width in digits
< 0.01 
      7 
  15 
widthCopy = x; 
< 0.01 
      7 
  16 
if isfloat(x) 
< 0.01 
      7 
  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 
      7 
  20 
    widthCopy(~isfinite(widthCopy)) = 314; 
      7 
  21 
    formatConversion = '.0f'; 
  22 
elseif isa(x, 'uint64')
  23 
    formatConversion = 'lu';
  24 
else
  25 
    formatConversion = 'ld';
  26 
end
  27 

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

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

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

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

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