This is a static copy of a profile reportHome
getfield (58358 calls, 3.645 sec)
Generated 05-Nov-2014 07:52:28 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/matlab/datatypes/getfield.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
37 | f = s.(deblank(strField)); % d... | 58358 | 0.701 s | 19.2% |  |
35 | strField = varargin{1}; | 58358 | 0.601 s | 16.5% |  |
36 | if (length(varargin)==1 &&... | 58358 | 0.591 s | 16.2% |  |
30 | if (isempty(varargin)) | 58358 | 0.421 s | 11.5% |  |
38 | return | 58358 | 0.260 s | 7.1% |  |
All other lines | | | 1.071 s | 29.4% |  |
Totals | | | 3.645 s | 100% | |
Children (called functions)
No childrenCode Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 59 |
Non-code lines (comments, blank lines) | 34 |
Code lines (lines that can run) | 25 |
Code lines that did run | 5 |
Code lines that did not run | 20 |
Coverage (did run/can run) | 20.00 % |
Function listing
time calls line
1 function f = getfield(s,varargin)
2 %GETFIELD Get structure field contents.
3 % F = GETFIELD(S,'field') returns the contents of the specified
4 % field. This is equivalent to the syntax F = S.field.
5 % S must be a 1-by-1 structure.
6 %
7 % F = GETFIELD(S,{i,j},'field',{k}) is equivalent to the syntax
8 % F = S(i,j).field(k).
9 %
10 % In other words, F = GETFIELD(S,sub1,sub2,...) returns the
11 % contents of the structure S using the subscripts or field
12 % references specified in sub1,sub2,etc. Each set of subscripts in
13 % parentheses must be enclosed in a cell array and passed to
14 % GETFIELD as a separate input. Field references are passed as
15 % strings.
16 %
17 % Note that if the evaluation of the specified subscripts results
18 % in a comma separated list, then GETFIELD will return the value
19 % corresponding to the first element in the comma separated list.
20 %
21 % For improved performance, when getting the value of a simple
22 % field, use <a href="matlab:helpview([docroot '/techdoc/matlab_prog/matlab_prog.map'],'dynamic_field_names')">dynamic field names</a>.
23 %
24 % See also SETFIELD, ISFIELD, FIELDNAMES, ORDERFIELDS, RMFIELD.
25
26 % Copyright 1984-2007 The MathWorks, Inc.
27 % $Revision: 1.21.4.6 $ $Date: 2010/08/23 23:07:49 $
28
29 % Check for sufficient inputs
0.42 58358 30 if (isempty(varargin))
31 error(message('MATLAB:getfield:InsufficientInputs'))
32 end
33
34 % The most common case
0.60 58358 35 strField = varargin{1};
0.59 58358 36 if (length(varargin)==1 && ischar(strField))
0.70 58358 37 f = s.(deblank(strField)); % deblank field name
0.26 58358 38 return
39 end
40
41 f = s;
42 for i = 1:length(varargin)
43 index = varargin{i};
44 if (isa(index, 'cell'))
45 f = f(index{:});
46 elseif ischar(index)
47
48 % Return the first element, if a comma separated list is generated
49 try
50 f = f.(deblank(index)); % deblank field name
51 catch exception %#ok
52 tmp = cell(1,length(f));
53 [tmp{:}] = deal(f.(deblank(index)));
54 f = tmp{1};
55 end
56 else
57 error(message('MATLAB:getfield:InvalidType'));
58 end
59 end
Other subfunctions in this file are not included in this listing.