This is a static copy of a profile reportHome
validatestring (2 calls, 0.010 sec)
Generated 05-Nov-2014 07:53:12 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/matlab/lang/validatestring.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
iptgetpref | function | 2 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
58 | [ in, validStrings, fname, arg... | 2 | 0.010 s | 100.0% |  |
81 | end | 2 | 0 s | 0% |  |
66 | out = checkString( in, validSt... | 2 | 0 s | 0% |  |
64 | try | 2 | 0 s | 0% |  |
57 | try | 2 | 0 s | 0% |  |
All other lines | | | 0 s | 0% |  |
Totals | | | 0.010 s | 100% | |
Children (called functions)
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 81 |
Non-code lines (comments, blank lines) | 64 |
Code lines (lines that can run) | 17 |
Code lines that did run | 6 |
Code lines that did not run | 11 |
Coverage (did run/can run) | 35.29 % |
Function listing
time calls line
1 function out = validatestring( varargin )
2 %VALIDATESTRING Check validity of text string.
3 % VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS) checks the validity of
4 % text string STR. If STR is an unambiguous, case-insensitive match to
5 % one or more strings in cell array VALID_STRINGS, VALIDATESTRING returns
6 % the matching string in VALIDSTR. Otherwise, VALIDATESTRING issues a
7 % formatted error message.
8 %
9 % VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS,ARG_INDEX) includes the
10 % position of the input in your function argument list as part of any
11 % generated error messages.
12 %
13 % VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS,FUNC_NAME) includes the
14 % specified function name in generated error identifiers.
15 %
16 % VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS,FUNC_NAME,VAR_NAME) includes
17 % the specified variable name in generated error messages.
18 %
19 % VALIDSTR = VALIDATESTRING(STR,VALID_STRINGS,FUNC_NAME,VAR_NAME,ARG_INDEX)
20 % includes the specified information in the generated error messages or
21 % identifiers.
22 %
23 % Input Arguments:
24 %
25 % VALID_STRINGS Cell array of text strings.
26 %
27 % ARG_INDEX Positive integer that specifies the position of the
28 % input argument.
29 %
30 % FUNC_NAME String that specifies the function name. If you specify
31 % an empty string, '', FUNCNAME is ignored.
32 %
33 % VAR_NAME String that specifies input argument name. If you
34 % specify an empty string, '', VARNAME is ignored.
35 %
36 % Example: Define a cell array of text strings, and pass in another
37 % string that is not in the cell array.
38 %
39 % validatestring('C',{'A','B'},'func_name','var_name',2)
40 %
41 % This code throws an error and displays a formatted message:
42 %
43 % Error using func_name
44 % Expected argument 2, var_name, to match one of these strings:
45 %
46 % A, B
47 %
48 % The input, 'C', did not match any of the valid strings.
49 %
50 % See also validateattributes, inputParser.
51
52 % Copyright 1993-2011 The MathWorks, Inc.
53 % $Revision: 1.1.6.7 $ $Date: 2011/04/16 06:39:29 $
54
2 55 narginchk(2,5);
56
2 57 try
0.01 2 58 [ in, validStrings, fname, argDes ] = checkInputs( varargin );
59 catch e
60 % only VALIDATESTRING should be on the stack
61 throw(e)
62 end
63
2 64 try
65 % check the contents of IN
2 66 out = checkString( in, validStrings, fname, argDes );
67
68 catch e
69 myId = 'MATLAB:validatestring:';
70 if strncmp( myId, e.identifier, length(myId) )
71 % leave VALIDATESTRING on the stack, because there was a misuse
72 % of VALIDATESTRING itself
73 throw(e)
74 else
75 % strip VALIDATESTRING off the stack so that the error looks like
76 % it comes from the caller just as if it had hand-coded its input checking
77 throwAsCaller( e )
78 end
79 end
80
2 81 end
Other subfunctions in this file are not included in this listing.