This is a static copy of a profile report

Home

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

Home

strcat (Calls: 3, Time: 0.012 s)
Generated 01-May-2020 20:23:05 using performance time.
function in file /Applications/MATLAB_R2018a.app/toolbox/matlab/strfun/strcat.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
pathfunction3
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
86
s0 =  blanks(space);
30.002 s16.8%
48
end
60.001 s7.5%
44
input = varargin{i};
60.001 s7.2%
56
twod = (cellfun('ndims', varar...
30.001 s6.5%
45
if ~isnumeric(input) &&...
60.001 s6.0%
All other lines  0.007 s56.0%
Totals  0.012 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
blanksfunction30.002 s13.6%
Self time (built-ins, overhead, etc.)  0.011 s86.4%
Totals  0.012 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function116
Non-code lines (comments, blank lines)54
Code lines (lines that can run)62
Code lines that did run46
Code lines that did not run16
Coverage (did run/can run)74.19 %
Function listing
time 
Calls 
 line
   1 
function t = strcat(varargin)
   2 
%STRCAT Concatenate text.
   3 
%   COMBINEDSTR = STRCAT(S1, S2, ..., SN) horizontally concatenates text
   4 
%   in arrays S1, S2, ..., SN. Inputs can be combinations of character
   5 
%   vectors, character vectors in scalar cells, character arrays with the
   6 
%   same number of rows, same-sized cell arrays of character vectors,
   7 
%   scalar strings, or same-sized string arrays. If any input is a string
   8 
%   array, COMBINEDSTR is a string array. Otherwise, if any input is a cell
   9 
%   array, COMBINEDSTR is a cell array.  Otherwise, COMBINEDSTR is a 
  10 
%   character array.
  11 
%
  12 
%   Notes:
  13 
%
  14 
%   For character array inputs, STRCAT removes trailing ASCII white-space
  15 
%   characters: space, tab, vertical tab, newline, carriage return, and
  16 
%   form-feed. To preserve trailing spaces when concatenating character
  17 
%   arrays, use horizontal array concatenation, [s1, s2, ..., sN].
  18 
%
  19 
%   For string and cell array inputs, STRCAT does not remove trailing white
  20 
%   space.
  21 
%
  22 
%   When combining nonscalar string or cell arrays with multi-row character
  23 
%   arrays, the string or cell arrays must be column vectors with the same
  24 
%   number of rows as the character arrays.
  25 
%
  26 
%   Example:
  27 
%
  28 
%       strcat({'Red','Yellow'},{'Green','Blue'})
  29 
%
  30 
%   returns
  31 
%
  32 
%       'RedGreen'    'YellowBlue'
  33 
%
  34 
%   See also CAT, CELLSTR, STRING.
  35 

  36 
%   Copyright 1984-2016 The MathWorks, Inc.
  37 

  38 
%   The cell array implementation is in @cell/strcat.m
  39 
%   The string array implementation is in @string/strcat.m
  40 

< 0.001 
      3 
  41
narginchk(1, inf); 
  42 

< 0.001 
      3 
  43
for i = 1:nargin 
< 0.001 
      6 
  44
    input = varargin{i}; 
< 0.001 
      6 
  45
    if ~isnumeric(input) && ~ischar(input) && ~iscell(input) 
  46 
        error(message('MATLAB:strcat:InvalidInputType'));
  47 
    end
< 0.001 
      6 
  48
end 
  49 

  50 
% Initialize return arguments
< 0.001 
      3 
  51
t = ''; 
  52 

  53 
% Get number of rows of each input
< 0.001 
      3 
  54
rows = cellfun('size', varargin, 1); 
  55 
% Get number of dimensions of each input
< 0.001 
      3 
  56
twod = (cellfun('ndims', varargin) == 2); 
  57 

  58 
% Return empty string when all inputs are empty
< 0.001 
      3 
  59
if all(rows == 0) 
  60 
    return;
  61 
end
< 0.001 
      3 
  62
if ~all(twod) 
  63 
    error(message('MATLAB:strfun:InputDimension'));
  64 
end
  65 

  66 
% Remove empty inputs
< 0.001 
      3 
  67
k = (rows == 0); 
< 0.001 
      3 
  68
varargin(k) = []; 
< 0.001 
      3 
  69
rows(k) = []; 
< 0.001 
      3 
  70
maxrows = max(rows); 
  71 
% Scalar expansion
  72 

< 0.001 
      3 
  73
for i = 1:length(varargin) 
< 0.001 
      6 
  74
    if rows(i) == 1 && rows(i) < maxrows 
  75 
        varargin{i} = varargin{i}(ones(1,maxrows), :);
  76 
        rows(i) = maxrows;
  77 
    end
< 0.001 
      6 
  78
end 
  79 

< 0.001 
      3 
  80
if any(rows ~= rows(1)) 
  81 
    error(message('MATLAB:strcat:NumberOfInputRows'));
  82 
end
  83 

< 0.001 
      3 
  84
n = rows(1); 
< 0.001 
      3 
  85
space = sum(cellfun('prodofsize', varargin)); 
  0.002 
      3 
  86
s0 =  blanks(space); 
< 0.001 
      3 
  87
scell = cell(1, n); 
< 0.001 
      3 
  88
notempty = true(1, n); 
< 0.001 
      3 
  89
s = ''; 
< 0.001 
      3 
  90
for i = 1:n 
< 0.001 
      3 
  91
    s = s0; 
< 0.001 
      3 
  92
    input = varargin{1}(i, :); 
< 0.001 
      3 
  93
    if ~isempty(input) && (input(end) == 0 || isspace(input(end))) 
  94 
        input = char(deblank(input));
  95 
    end
< 0.001 
      3 
  96
    pos = length(input); 
< 0.001 
      3 
  97
    s(1:pos) = input; 
< 0.001 
      3 
  98
    pos = pos + 1; 
< 0.001 
      3 
  99
    for j = 2:length(varargin) 
< 0.001 
      3 
 100
        input = varargin{j}(i, :); 
< 0.001 
      3 
 101
        if ~isempty(input) && (input(end) == 0 || isspace(input(end))) 
 102 
            input = char(deblank(input));
 103 
        end
< 0.001 
      3 
 104
        len = length(input); 
< 0.001 
      3 
 105
        s(pos:pos+len-1) = input; 
< 0.001 
      3 
 106
        pos = pos + len; 
< 0.001 
      3 
 107
    end 
< 0.001 
      3 
 108
    s = s(1:pos-1); 
< 0.001 
      3 
 109
    notempty(1, i) = ~isempty(s); 
< 0.001 
      3 
 110
    scell{1, i} = s; 
< 0.001 
      3 
 111
end 
< 0.001 
      3 
 112
if n > 1 
 113 
    t = char(scell{notempty});
< 0.001 
      3 
 114
else 
< 0.001 
      3 
 115
    t = s; 
< 0.001 
      3 
 116
end 

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