This is a static copy of a profile report

Home

validatestring>checkString (6 calls, 0.000 sec)
Generated 14-Nov-2016 07:47:24 using cpu time.
subfunction in file /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/lang/validatestring.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
validatestringfunction6
Lines where the most time was spent
No measurable time spent in this function

Line NumberCodeCallsTotal Time% TimeTime Plot
141
end
60 s0%
109
out = out{1};
60 s0%
107
if numel( out ) == 1
60 s0%
105
end
60 s0%
104
out = validStrings( strncmpi( ...
60 s0%
All other lines  0 s0%
Totals  0 s0% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function60
Non-code lines (comments, blank lines)25
Code lines (lines that can run)35
Code lines that did run11
Code lines that did not run24
Coverage (did run/can run)31.43 %
Function listing
time 
calls 
 line
  82 
function out = checkString( in, validStrings, optional_inputs )
  83 

      6 
  84 
try 
      6 
  85 
    if ~(ischar(in) && strcmp(in,'')) 
      6 
  86 
        validateattributes( in, {'char'}, {'row'} ); 
      6 
  87 
    end 
  88 
catch e
  89 
    [ fname, msgId, argname, argpos ] = matlab.internal.validators.generateArgumentDescriptor( ...
  90 
        optional_inputs, 'validatestring' );
  91 
    argDes = matlab.internal.validators.getArgumentDescriptor( msgId, argname, argpos );
  92 
    me = MException( matlab.internal.validators.generateId( fname, 'unrecognizedStringChoice' ),...
  93 
        '%s', getString(message( 'MATLAB:validatestring:unrecognizedStringChoice2', ...
  94 
                    argDes, validStringList( validStrings ))));
  95 
    me = me.addCause( e );
  96 
    throwAsCaller(me);
  97 
end
  98 

  99 
% do a case insensitive search, but use the case from validStrings,
 100 
% not the case from the input
      6 
 101 
if isempty(in) 
 102 
    out = validStrings( ismember(validStrings,in) );
      6 
 103 
else 
      6 
 104 
    out = validStrings( strncmpi( in, validStrings, length(in) ) ); 
      6 
 105 
end 
 106 

      6 
 107 
if numel( out ) == 1 
 108 
    % unambiguous match
      6 
 109 
    out = out{1}; 
 110 
elseif numel( out ) > 1
 111 
    % possibly ambiguous match
 112 
    
 113 
    % determine if all the matching strings are substrings of each other
 114 
    [ shortestMatchLength, shortestMatchIdx] = min( cellfun( @length, out ) );
 115 
    shortestMatch = out{shortestMatchIdx};
 116 
    allSubstrings = all( strncmpi( shortestMatch, out, shortestMatchLength ) );
 117 
        
 118 
    if allSubstrings
 119 
        % return the shortest match
 120 
        out = shortestMatch;
 121 
    else
 122 
        [ fname, msgId, argname, argpos ] = matlab.internal.validators.generateArgumentDescriptor( ...
 123 
            optional_inputs, 'validatestring' );
 124 
        argDes = matlab.internal.validators.getArgumentDescriptor( msgId, argname, argpos );
 125 

 126 
        error( matlab.internal.validators.generateId( fname, 'ambiguousStringChoice' ), '%s', ...
 127 
            getString(message('MATLAB:validatestring:ambiguousStringChoice', ...
 128 
            argDes, validStringList( validStrings ), in)))
 129 
    end
 130 
else
 131 
    % no match found
 132 
    [ fname, msgId, argname, argpos ] = matlab.internal.validators.generateArgumentDescriptor( ...
 133 
        optional_inputs, 'validatestring' );
 134 
    argDes = matlab.internal.validators.getArgumentDescriptor( msgId, argname, argpos );
 135 

 136 
    error( matlab.internal.validators.generateId( fname, 'unrecognizedStringChoice' ), '%s', ...
 137 
        getString(message('MATLAB:validatestring:unrecognizedStringChoice3', ...
 138 
        argDes, validStringList( validStrings ), in )));
 139 
end
 140 

      6 
 141 
end 

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