This is a static copy of a profile report

Home

tabular.subsrefBraces (Calls: 37754, Time: 2.654 s)
Generated 04-Jun-2021 04:11:12 using performance time.
function in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\datatypes\tabular\@tabular\subsrefBraces.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
tabular.subsreffunction37754
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
23
varIndices = t.varDim.subs2ind...
377541.822 s68.7%
20
[rowIndices,numRowIndices] = t...
377540.476 s17.9%
15
if numel(s(1).subs) ~= t.metaD...
377540.096 s3.6%
50
varargout{1} = b;
377540.084 s3.2%
86
end
377540.043 s1.6%
All other lines  0.132 s5.0%
Totals  2.654 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
varNamesDim>varNamesDim.subs2indsclass method377541.582 s59.6%
...mension>tabularDimension.subs2indsclass method377540.345 s13.0%
categorical.parenReferencefunction2780.004 s0.2%
categorical.ismatrixfunction2780.001 s0.0%
Self time (built-ins, overhead, etc.)  0.721 s27.2%
Totals  2.654 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function86
Non-code lines (comments, blank lines)38
Code lines (lines that can run)48
Code lines that did run18
Code lines that did not run30
Coverage (did run/can run)37.50 %
Function listing
time 
Calls 
 line
   1 
function [varargout] = subsrefBraces(t,s)
   2 
%SUBSREFBRACES Subscripted reference for a table.
   3 

   4 
%   Copyright 2012-2019 The MathWorks, Inc.
   5 

   6 
import matlab.internal.datatypes.isColon
  0.021 
  37754 
   7
subsType = matlab.internal.tabular.private.tabularDimension.subsType; % "import" for calls to subs2inds 
   8 

   9 
% '{}' is a reference to the contents of a subset of a table.  If no
  10 
% subscripting follows, return those contents as a single array of whatever
  11 
% type they are.  Any sort of subscripting may follow.
  12 

  0.002 
  37754 
  13
if ~isstruct(s), s = substruct('{}',s); end 
  14 

  0.096 
  37754 
  15
if numel(s(1).subs) ~= t.metaDim.length 
  16 
    error(message('MATLAB:table:NDSubscript'));
  0.001 
  37754 
  17
end 
  18 

  19 
% Translate row labels into indices (leaves logical and ':' alone)
  0.476 
  37754 
  20
[rowIndices,numRowIndices] = t.rowDim.subs2inds(s(1).subs{1}); 
  21 

  22 
% Translate variable (column) names into indices (translates logical and ':')
  1.822 
  37754 
  23
varIndices = t.varDim.subs2inds(s(1).subs{2},subsType.reference,t.data); 
  24 

  25 
% Extract the specified variables as a single array.
  0.002 
  37754 
  26
if isscalar(varIndices) 
  0.040 
  37754 
  27
    b = t.data{varIndices}; 
  28 
else
  29 
    b = t.extractData(varIndices);
  0.002 
  37754 
  30
end 
  31 

  32 
% Retain only the specified rows.
  0.005 
  37754 
  33
if isa(b,'tabular') 
  34 
    b = b.subsrefParens({rowIndices ':'}); % force dispatch to overloaded table subscripting
  0.004 
  37754 
  35
elseif ismatrix(b) 
  0.007 
  37754 
  36
    b = b(rowIndices,:); % without using reshape, may not have one 
  37 
else
  38 
    % The contents could have any number of dims.  Treat it as 2D to get
  39 
    % the necessary row, and then reshape to its original dims.
  40 
    outSz = size(b); outSz(1) = numRowIndices;
  41 
    b = reshape(b(rowIndices,:), outSz);
  0.002 
  37754 
  42
end 
  43 

  0.003 
  37754 
  44
if isscalar(s) 
  45 
    % If there's no additional subscripting, return the table contents.
  0.002 
  37754 
  46
    if nargout > 1 
  47 
        % Output of table brace subscripting will always be scalar
  48 
        error(message('MATLAB:table:TooManyOutputsBracesIndexing'));
  0.002 
  37754 
  49
    end 
  0.084 
  37754 
  50
    varargout{1} = b; 
  51 
else
  52 
    if s(2).type ~= "."  % t{rows,vars}(...) or t{rows,vars}{...}
  53 
        rowIndices = s(2).subs{1};
  54 
        if isnumeric(rowIndices) || islogical(rowIndices) || isColon(rowIndices)
  55 
            % Can leave these alone to save overhead of calling subs2inds
  56 
        else
  57 
            % The second level of braces-parens or braces-braces subscripting might use row
  58 
            % labels inherited from the table's rows, translate those to indices.
  59 
            rowIndices = t.rowDim.subs2inds(rowIndices);
  60 
            if (size(b,2)>1) && isscalar(s(2).subs)
  61 
                error(message('MATLAB:table:InvalidLinearIndexing'));
  62 
            end
  63 
            s(2).subs{1} = rowIndices;
  64 
        end
  65 
    else
  66 
        % A reference to a property or field, so no row labels
  67 
    end
  68 
    
  69 
    % Let b's subsref handle any remaining additional subscripting.  This may
  70 
    % return a comma-separated list when the cascaded subscripts resolve to
  71 
    % multiple things, so ask for and assign to as many outputs as we're
  72 
    % given. That is the number of outputs on the LHS of the original expression,
  73 
    % or if there was no LHS, it comes from numArgumentsFromSubscript.
  74 
    if length(s) == 2
  75 
        try %#ok<ALIGN>
  76 
            [varargout{1:nargout}] = subsref(b,s(2)); % dispatches correctly, even to tabular
  77 
        catch ME, throw(ME); end
  78 
    else % length(s) > 2
  79 
        % Trick the third and higher levels of subscripting in things like
  80 
        % t.Var{i}(...) etc. into dispatching to the right place when
  81 
        % t.Var{i}, or something further down the chain, is itself a table.
  82 
        try %#ok<ALIGN>
  83 
            [varargout{1:nargout}] = matlab.internal.tabular.private.subsrefRecurser(b,s(2:end));
  84 
        catch ME, rethrow(ME); end % point to the line in subsrefRecurser
  85 
    end
  0.043 
  37754 
  86
end 

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