This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
script9script6
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
120
b = b(rowIndices,colIndices);
60.002 s54.2%
37
varIndex = find(matches(t.varD...
60.000 s10.1%
117
if isa(b,'tabular')
60.000 s6.3%
86
b = t.data{varIndex};
60.000 s4.9%
36
elseif ischar(varName) &&a...
60.000 s4.7%
All other lines  0.001 s19.7%
Totals  0.003 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
categorical.parenReferencefunction60.001 s37.4%
Self time (built-ins, overhead, etc.)  0.002 s62.6%
Totals  0.003 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function128
Non-code lines (comments, blank lines)45
Code lines (lines that can run)83
Code lines that did run18
Code lines that did not run65
Coverage (did run/can run)21.69 %
Function listing
time 
Calls 
 line
   1 
function b = dotParenReference(t,varName,rowIndices,colIndices,varargin)
   2 
%DOTPARENREFERENCE Dot-parens subscripted reference for a table.
   3 

   4 
% This function is for internal use only and will change in a
   5 
% future release.  Do not use this function.
   6 

   7 
%   Copyright 2015-2019 The MathWorks, Inc.
   8 

   9 
import matlab.internal.datatypes.isColon
  10 
import matlab.internal.datatypes.isScalarInt
  11 
import matlab.internal.datatypes.tryThrowIllegalDotMethodError
  12 
import matlab.lang.correction.ReplaceIdentifierCorrection
  13 

  14 
% dotParenReference is called directly for RHS subscripting expressions such as
  15 
%    t.Var(rowindices) or t.Var(rowindices,...)
  16 
%    t.Var(rownames)   or t.Var(rownames,...)
  17 
% but not (yet) for dynamic field references. This method is also called directly
  18 
% when there is deeper subscripting
  19 
%    t.Var(...)[anything else]
  20 
% where [anything else] is handled afterwards by the caller (assuming it
  21 
% is not illegal to begin with:"()-indexing must appear last"). With parens
  22 
% as the last level of subscripting, no need to worry about varargout.
  23 

  24 
% Translate variable (column) name into an index. Avoid overhead of
  25 
% t.varDim.subs2inds in this simple case.
< 0.001 
      6 
  26
if isnumeric(varName) 
  27 
    % Allow t.(i) where i is an integer
  28 
    varIndex = varName;
  29 
    if ~isScalarInt(varIndex,1)
  30 
        error(message('MATLAB:table:IllegalVarIndex'));
  31 
    elseif varIndex > t.varDim.length
  32 
        error(message('MATLAB:table:VarIndexOutOfRange'));
  33 
    end
  34 
    % Allow t.(i) where i is an integer
  35 
    varIndex = varName;
< 0.001 
      6 
  36
elseif ischar(varName) && (isrow(varName) || isequal(varName,'')) % isCharString(varName) 
< 0.001 
      6 
  37
    varIndex = find(matches(t.varDim.labels,varName)); 
< 0.001 
      6 
  38
    if isempty(varIndex) 
  39 
        if matches(varName,t.metaDim.labels{1})
  40 
            % If it's the row dimension name, index into the row labels
  41 
            varIndex = 0;
  42 
        elseif matches(varName,t.metaDim.labels{2})
  43 
            % If it's the vars dimension name, subscripting into that is not supported,
  44 
            % must use explicit braces for that.
  45 
            error(message('MATLAB:table:NestedSubscriptingWithDotVariables',t.metaDim.labels{2}));
  46 
        
  47 
        else
  48 
            % If there's no such var, it may be a reference to a property, but
  49 
            % without the '.Properties'. Give a helpful error message. Neither
  50 
            % t.Properties or t.Properties.PropName end up here, those go to
  51 
            % subsrefDot.
  52 
            match = find(matches(t.propertyNames,varName,"IgnoreCase",true),1);
  53 
            if ~isempty(match)
  54 
                match = t.propertyNames{match};
  55 
                if matches(varName,match) % a valid property name
  56 
                    throw(MException(message('MATLAB:table:IllegalPropertyReference',varName)) ...
  57 
                        .addCorrection(ReplaceIdentifierCorrection(varName,append('Properties.',match))));
  58 
                else % a property name, but with wrong case
  59 
                    throw(MException(message('MATLAB:table:IllegalPropertyReferenceCase',varName,match)) ...
  60 
                        .addCorrection(ReplaceIdentifierCorrection(varName,append('Properties.',match))));
  61 
                end
  62 
            else
  63 
                match = matches(t.varDim.labels,varName,'IgnoreCase',true);
  64 
                if any(match) % an existing variable name
  65 
                    match = t.varDim.labels{match};
  66 
                    throw(MException(message('MATLAB:table:UnrecognizedVarNameCase',varName,match)) ...
  67 
                        .addCorrection(ReplaceIdentifierCorrection(varName,match)));
  68 
                elseif matches(varName,t.metaDim.labels{1},'IgnoreCase',true) % the row dimension name
  69 
                    throw(MException(message('MATLAB:table:RowDimNameCase',varName,t.metaDim.labels{1})) ...
  70 
                    	.addCorrection(ReplaceIdentifierCorrection(varName,t.metaDim.labels{1})));
  71 
                elseif matches(t.defaultDimNames{1},varName) % trying to access row labels by default name
  72 
                    throw(t.throwSubclassSpecificError('RowDimNameNondefault',varName,t.metaDim.labels{1}) ...
  73 
                    	.addCorrection(ReplaceIdentifierCorrection(varName,t.metaDim.labels{1})));
  74 
                else
  75 
                    tryThrowIllegalDotMethodError(t,varName,'MethodsWithNoCorrection',t.methodsWithNonTabularFirstArgument,'MessageCatalog','MATLAB:table');
  76 
                    error(message('MATLAB:table:UnrecognizedVarName',varName));
  77 
                end
  78 
            end
  79 
        end
< 0.001 
      6 
  80
    end 
  81 
else
  82 
    error(message('MATLAB:table:IllegalVarSubscript'));
< 0.001 
      6 
  83
end 
  84 

< 0.001 
      6 
  85
if varIndex > 0 
< 0.001 
      6 
  86
    b = t.data{varIndex}; 
  87 
elseif varIndex == 0
  88 
    b = t.rowDim.labels;
  89 
else % varIndex == -1, all variables
  90 
    assert(false);
< 0.001 
      6 
  91
end 
  92 

< 0.001 
      6 
  93
if isnumeric(rowIndices) || islogical(rowIndices) || isColon(rowIndices) 
  94 
    % Can leave these alone to save overhead of calling subs2inds
  95 
else
  96 
    % Dot-parens or dot-braces subscripting might use row labels inherited from the
  97 
    % table, translate those to indices.
  98 
    if ~iscolumn(b) && (nargin < 4)
  99 
        error(message('MATLAB:table:InvalidLinearIndexing'));
 100 
    end
 101 
    numericRowIndices = t.rowDim.subs2inds(rowIndices);
 102 
    % subs2inds returns the indices as a col vector, but subscripting on a table
 103 
    % variable (as opposed to on a table) should follow the usual reshaping rules.
 104 
    % Nothing to do for one (char) name, including ':', but preserve a cellstr
 105 
    % subscript's original shape.
 106 
    if iscell(rowIndices) || isstring(rowIndices), numericRowIndices = reshape(numericRowIndices,size(rowIndices)); end
 107 
    rowIndices = numericRowIndices;
< 0.001 
      6 
 108
end 
 109 

< 0.001 
      6 
 110
if nargin == 3 
 111 
    if isa(b,'tabular')
 112 
        b = b.subsrefParens({rowIndices}); % get the tabular error for linear indexing
 113 
    else
 114 
        b = b(rowIndices);
 115 
    end
< 0.001 
      6 
 116
elseif nargin == 4 
< 0.001 
      6 
 117
    if isa(b,'tabular') 
 118 
        b = b.subsrefParens({rowIndices colIndices});
< 0.001 
      6 
 119
    else 
  0.002 
      6 
 120
        b = b(rowIndices,colIndices); 
< 0.001 
      6 
 121
    end 
 122 
else
 123 
    if isa(b,'tabular')
 124 
        b = b.subsrefParens([rowIndices colIndices varargin{:}]); % get the tabular error for N-D indexing
 125 
    else
 126 
        b = b(rowIndices,colIndices,varargin{:});
 127 
    end
< 0.001 
      6 
 128
end 

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