This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
analyze_SNPs_hapmapfunction1
Load_genome_informationfunction64
LOH_hapmap_v4function54
FindChrSizes_4function16
calculate_allelic_ratio_cutoffsscript120
angle_plot_subfiguresscript344
allelic_ratios_WGseqfunction24
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
69
s = int2str(x); % Enhance the ...
4710.111 s47.8%
85
[s, forceWidth, f] = handleNum...
1520.020 s8.7%
64
widthCopy(~isfinite(widthCopy)...
6230.020 s8.7%
35
narginchk(1,2);
6230.020 s8.7%
81
else
1520.010 s4.3%
All other lines  0.050 s21.7%
Totals  0.232 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
int2strfunction4710.111 s47.8%
num2str>handleNumericPrecisionsubfunction1520.020 s8.7%
Self time (built-ins, overhead, etc.)  0.101 s43.5%
Totals  0.232 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function161
Non-code lines (comments, blank lines)59
Code lines (lines that can run)102
Code lines that did run30
Code lines that did not run72
Coverage (did run/can run)29.41 %
Function listing
time 
calls 
 line
   1 
function s = num2str(x, f)
   2 
%NUM2STR Convert numbers to a string.
   3 
%   T = NUM2STR(X) converts the matrix X into a string representation T
   4 
%   with about 4 digits and an exponent if required.  This is useful for
   5 
%   labeling plots with the TITLE, XLABEL, YLABEL, and TEXT commands.
   6 
%
   7 
%   T = NUM2STR(X,N) converts the matrix X into a string representation
   8 
%   with a maximum N digits of precision.  The default number of digits is
   9 
%   based on the magnitude of the elements of X.
  10 
%
  11 
%   T = NUM2STR(X,FORMAT) uses the format string FORMAT (see SPRINTF for
  12 
%   details).
  13 
%
  14 
%   Example 1:
  15 
%       num2str(randn(2,2),3) produces a string matrix such as
  16 
%
  17 
%        1.44    -0.755
  18 
%       0.325      1.37
  19 
%
  20 
%   Example 2:
  21 
%       num2str(rand(2,3) * 9999, '%10.5e\n') produces a string matrix
  22 
%       such as
  23 
%
  24 
%       8.14642e+03
  25 
%       1.26974e+03
  26 
%       6.32296e+03
  27 
%       9.05701e+03
  28 
%       9.13285e+03
  29 
%       9.75307e+02
  30 
%
  31 
%   See also INT2STR, SPRINTF, FPRINTF, MAT2STR.
  32 

  33 
%   Copyright 1984-2012 The MathWorks, Inc.
  34 
%------------------------------------------------------------------------------
  0.02 
    623 
  35 
    narginchk(1,2); 
    623 
  36 
    if ischar(x) 
  37 
        s = x;
  38 
        return;
  39 
    end
    623 
  40 
    if isempty(x) 
  41 
        s = '';
  42 
        return
  43 
    end
    623 
  44 
    if isfloat(x) 
    623 
  45 
        x = 0+x;  % Remove negative zero 
    623 
  46 
    end 
    623 
  47 
    if issparse(x) 
  48 
        x = full(x);
  49 
    end
    623 
  50 
    intFieldExtra = 1; 
    623 
  51 
    maxFieldWidth = 12; 
    623 
  52 
    floatWidthOffset = 4; 
    623 
  53 
    forceWidth = 0; 
  0.01 
    623 
  54 
    padColumnsWithSpace = true; 
  55 
    % Compose sprintf format string of numeric array.
  56 
        
    623 
  57 
    if nargin < 2 || (isinteger(x) && isnumeric(f)) 
  58 
        
  59 
        % To get the width of the elements in the output string
  0.01 
    623 
  60 
        widthCopy = x; 
  61 
        % replace Inf and NaN with a number of equivalent length (3 digits) for width
  62 
        % calcultion
    623 
  63 
        if isfloat(x) 
  0.02 
    623 
  64 
            widthCopy(~isfinite(widthCopy)) = 314; %This could be any 3 digit number 
    623 
  65 
        end 
  0.01 
    623 
  66 
        xmax = double(max(abs(widthCopy(:)))); 
  0.01 
    623 
  67 
        if isequaln(x, fix(x)) && (isinteger(x) || eps(xmax) <= 1) 
  0.01 
    471 
  68 
            if isreal(x) 
  0.11 
    471 
  69 
                s = int2str(x); % Enhance the performance 
    471 
  70 
                return; 
  71 
            end         
  72 

  73 
            d = min(maxFieldWidth, floor(log10(xmax)) + 1);
  74 
            forceWidth = d+intFieldExtra;
  75 
            f = '%d';
    152 
  76 
        else 
  77 
            % The precision is unspecified; the numeric array contains floating point
  78 
            % numbers.
    152 
  79 
            if xmax == 0 
  80 
                d = 1;
  0.01 
    152 
  81 
            else 
    152 
  82 
                d = min(maxFieldWidth, max(1, floor(log10(xmax))+1))+floatWidthOffset; 
    152 
  83 
            end 
  84 
            
  0.02 
    152 
  85 
            [s, forceWidth, f] = handleNumericPrecision(x, d); 
  86 

    152 
  87 
            if ~isempty(s) 
    152 
  88 
                return; 
  89 
            end
  90 
        end
  91 
    elseif isnumeric(f)
  92 
        f = round(real(f));
  93 

  94 
        [s, forceWidth, f] = handleNumericPrecision(x, f);
  95 

  96 
        if ~isempty(s)
  97 
            return;
  98 
        end
  99 
    elseif ischar(f)
 100 
        % Precision is specified as an ANSI C print format string.
 101 
        
 102 
        % Explicit format strings should be explicitly padded
 103 
        padColumnsWithSpace = false;
 104 
        
 105 
        % Validate format string
 106 
        k = strfind(f,'%');
 107 
        if isempty(k)
 108 
            error(message('MATLAB:num2str:fmtInvalid', f));
 109 
        end
 110 
    else
 111 
        error(message('MATLAB:num2str:invalidSecondArgument'))        
 112 
    end
 113 

 114 
    %-------------------------------------------------------------------------------
 115 
    % Print numeric array as a string image of itself.
 116 

 117 
    if isreal(x)
 118 
        [raw, isLeft] = cellPrintf(f, x, false);
 119 
        [m,n] = size(raw);
 120 
        cols = cell(1,n);
 121 
        widths = zeros(1,n);
 122 
        for j = 1:n
 123 
            if isLeft
 124 
                cols{j} = char(raw(:,j));
 125 
            else
 126 
                cols{j} = strvrcat(raw(:,j));
 127 
            end
 128 
            widths(j) = size(cols{j}, 2);
 129 
        end
 130 
    else
 131 
        forceWidth = 2*forceWidth + 2;
 132 
        raw = cellPrintf(f, real(x), false);
 133 
        imagRaw = cellPrintf(f, imag(x), true);
 134 
        [m,n] = size(raw);
 135 
        cols = cell(1,n);
 136 
        widths = zeros(1,n);
 137 
        for j = 1:n
 138 
            cols{j} = [strvrcat(raw(:,j)) char(imagRaw(:,j))];
 139 
            widths(j) = size(cols{j}, 2);
 140 
        end
 141 
    end
 142 

 143 
    maxWidth = max([widths forceWidth]);
 144 
    padWidths = maxWidth - widths;
 145 
    padIndex = find(padWidths, 1);
 146 
    while ~isempty(padIndex)
 147 
        padWidth = padWidths(padIndex);
 148 
        padCols = (padWidths==padWidth);
 149 
        padWidths(padCols) = 0;
 150 
        spaceCols = char(ones(m,padWidth)*' ');
 151 
        cols(padCols) = strcat({spaceCols}, cols(padCols));
 152 
        padIndex = find(padWidths, 1);
 153 
    end
 154 

 155 
    if padColumnsWithSpace
 156 
        spaceCols = char(ones(m,1)*' ');
 157 
        cols = strcat(cols, {spaceCols});
 158 
    end
 159 

 160 
    s = strtrim([cols{:}]);
 161 
end

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