This is a static copy of a profile report

Home

fcnchk (1730 calls, 0.197 sec)
Generated 05-Aug-2011 13:03:52 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/funfun/fcnchk.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
fminsearchfunction870
optimfcnchkfunction860
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
103
if nargout < 2, error(msg);...
8600.022 s11.1%
94
if isempty(theMessage)
8600.022 s11.1%
61
elseif isa(fun,'function_handl...
17300.022 s11.1%
32
if nin > 1 && strcm...
17300.022 s11.1%
89
if nargout < 2 && i...
17300.011 s5.6%
All other lines  0.098 s50.0%
Totals  0.197 s100% 
Children (called functions)
No children
Code Analyzer results
Line numberMessage
71STRMATCH will be removed in a future release. Use STRNCMP instead.
72STRMATCH will be removed in a future release. Use STRNCMP instead.
Coverage results
[ Show coverage for parent directory ]
Total lines in function103
Non-code lines (comments, blank lines)41
Code lines (lines that can run)62
Code lines that did run17
Code lines that did not run45
Coverage (did run/can run)27.42 %
Function listing
   time   calls  line
1 function [f,msg] = fcnchk(fun,varargin)
2 %FCNCHK Check FUNFUN function argument.
3 % FCNCHK(FUN,...) returns an inline object based on FUN if FUN
4 % is a string containing parentheses, variables, and math
5 % operators. FCNCHK simply returns FUN if FUN is a function handle,
6 % or a matlab object with an feval method (such as an inline object).
7 % If FUN is a string name of a function (e.g. 'sin'), FCNCHK returns a
8 % function handle to that function.
9 %
10 % FCNCHK is a helper function for FMINBND, FMINSEARCH, FZERO, etc. so they
11 % can compute with string expressions in addition to functions.
12 %
13 % FCNCHK(FUN,...,'vectorized') processes the string (e.g., replacing
14 % '*' with '.*') to produce a vectorized function.
15 %
16 % When FUN contains an expression then FCNCHK(FUN,...) is the same as
17 % INLINE(FUN,...) except that the optional trailing argument 'vectorized'
18 % can be used to produce a vectorized function.
19 %
20 % [F,MSG] = FCNCHK(...) returns an empty structure in MSG if successful
21 % or an error message structure if not.
22 %
23 % See also ERROR, INLINE, @.
24
25 % Copyright 1984-2010 The MathWorks, Inc.
26 % $Revision: 1.29.4.15 $ $Date: 2010/11/17 11:26:16 $
27
1730 28 theMessage = '';
1730 29 msgident = '';
30
1730 31 nin = nargin;
0.02 1730 32 if nin > 1 && strcmp(varargin{end},'vectorized')
33 vectorizing = true;
34 nin = nin - 1;
1730 35 else
1730 36 vectorizing = false;
0.01 1730 37 end
38
0.01 1730 39 if ischar(fun)
40 fun = strtrim_local_function(fun);
41 % Check for non-alphanumeric characters that must be part of an
42 % expression.
43 if isempty(fun),
44 f = inline('[]');
45 elseif ~vectorizing && isidentifier_local_function(fun)
46 f = str2func(fun); % Must be a function name only
47 % Note that we avoid collision of f = str2func(fun) with any local
48 % function named fun, by uglifying the local function's name
49 if isequal('x',fun)
50 warning(message('MATLAB:fcnchk:AmbiguousX'));
51 end
52 else
53 if vectorizing
54 f = inline(vectorize(fun),varargin{1:nin-1});
55 var = argnames(f);
56 f = inline([formula(f) '.*ones(size(' var{1} '))'],var{1:end});
57 else
58 f = inline(fun,varargin{1:nin-1});
59 end
60 end
0.02 1730 61 elseif isa(fun,'function_handle')
0.01 1730 62 f = fun;
63 % is it a matlab object with a feval method?
64 elseif isobject(fun)
65 % delay the methods call unless we know it is an object to avoid
66 % runtime error for compiler
67 [meths,cellInfo] = methods(class(fun),'-full');
68 if ~isempty(cellInfo) % if fun is an MCOS object
69 meths = cellInfo(:,3); % get methods names from cell array
70 end
71 if any(strmatch('feval',meths))
72 if vectorizing && any(strmatch('vectorize',meths))
73 f = vectorize(fun);
74 else
75 f = fun;
76 end
77 else % no feval method
78 f = '';
79 theMessage = 'If FUN is a MATLAB object, it must have an feval method.';
80 msgident = 'MATLAB:fcnchk:objectMissingFevalMethod';
81 end
82 else
83 f = '';
84 theMessage = 'FUN must be a function, a valid string expression, or an inline function object.';
85 msgident = 'MATLAB:fcnchk:invalidFunctionSpecifier';
86 end
87
88 % If no errors and nothing to report then we are done.
0.01 1730 89 if nargout < 2 && isempty(theMessage)
870 90 return
91 end
92
93 % compute MSG
0.02 860 94 if isempty(theMessage)
860 95 msg.message = '';
860 96 msg.identifier = '';
860 97 msg = msg(zeros(0,1)); % make sure msg is the right dimension
98 else
99 msg.message = theMessage;
100 msg.identifier = msgident;
101 end
102
0.02 860 103 if nargout < 2, error(msg); end

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