This is a static copy of a profile report

Home

Function details for int2strThis is a static copy of a profile report

Home

int2str (Calls: 3, Time: 0.003 s)
Generated 27-Jul-2019 12:51:46 using performance time.
function in file C:\Program Files\MATLAB\R2019a\toolbox\matlab\strfun\int2str.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
num2strfunction3
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
21
widthCopy(~isfinite(widthCopy)...
30.001 s23.2%
32
s = sprintf(['%', formatConver...
30.001 s18.0%
17
if isfloat(x)
30.000 s8.0%
31
elseif isscalar(x)
30.000 s5.9%
53
end
30.000 s0.1%
All other lines  0.001 s44.8%
Totals  0.003 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 run10
Code lines that did not run20
Coverage (did run/can run)33.33 %
Function listing
time 
Calls 
 line
   1 
function s = int2str(x)
   2 
%INT2STR Represent integers as character array
   3 
%   S = INT2STR(X) rounds the elements of numeric matrix X to integers and 
   4 
%   converts the result into a character array that represents the numbers.
   5 
%
   6 
%   INT2STR returns NaN and Inf elements as 'NaN' and 'Inf', respectively.
   7 
%
   8 
%   See also NUM2STR, SPRINTF, FPRINTF, MAT2STR.
   9 

  10 
%   Copyright 1984-2016 The MathWorks, Inc.
  11 

  12 
% only work with real portion of x
< 0.001 
      3 
  13
x = real(x); 
  14 

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

      3 
  29
if isempty(x) 
  30 
    s = '';
< 0.001 
      3 
  31
elseif isscalar(x) 
< 0.001 
      3 
  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);
< 0.001 
      3 
  53
end 

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