This is a static copy of a profile report

Home

setfield (57540 calls, 3.986 sec)
Generated 05-Nov-2014 07:52:28 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/matlab/datatypes/setfield.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ml_initparamfunction8
ml_parsecellfunction57532
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
34
s.(deblank(strField)) = vararg...
575401.132 s28.4%
35
return
575400.491 s12.3%
26
if (isempty(varargin) || lengt...
575400.391 s9.8%
32
strField = varargin{1};
575400.340 s8.5%
31
arglen = length(varargin);
575400.340 s8.5%
All other lines  1.292 s32.4%
Totals  3.986 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function58
Non-code lines (comments, blank lines)30
Code lines (lines that can run)28
Code lines that did run6
Code lines that did not run22
Coverage (did run/can run)21.43 %
Function listing
   time   calls  line
1 function s = setfield(s,varargin)
2 %SETFIELD Set structure field contents.
3 % S = SETFIELD(S,'field',V) sets the contents of the specified
4 % field to the value V. This is equivalent to the syntax S.field = V.
5 % S must be a 1-by-1 structure. The changed structure is returned.
6 %
7 % S = SETFIELD(S,{i,j},'field',{k},V) is equivalent to the syntax
8 % S(i,j).field(k) = V;
9 %
10 % In other words, S = SETFIELD(S,sub1,sub2,...,V) sets the
11 % contents of the structure S to V 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 % SETFIELD as a separate input. Field references are passed as
15 % strings.
16 %
17 % For improved performance, when setting the value of a simple
18 % field, use <a href="matlab:helpview([docroot '/techdoc/matlab_prog/matlab_prog.map'], 'dynamic_field_names')">dynamic field names</a>.
19 %
20 % See also GETFIELD, ISFIELD, FIELDNAMES, ORDERFIELDS, RMFIELD.
21
22 % Copyright 1984-2007 The MathWorks, Inc.
23 % $Revision: 1.22.4.9 $ $Date: 2010/08/23 23:07:53 $
24
25 % Check for sufficient inputs
0.39 57540 26 if (isempty(varargin) || length(varargin) < 2)
27 error(message('MATLAB:setfield:InsufficientInputs'));
28 end
29
30 % The most common case
0.34 57540 31 arglen = length(varargin);
0.34 57540 32 strField = varargin{1};
0.20 57540 33 if (arglen==2)
1.13 57540 34 s.(deblank(strField)) = varargin{end};
0.49 57540 35 return
36 end
37
38 subs = varargin(1:end-1);
39 types = cell(1, arglen-1);
40 for i = 1:arglen-1
41 index = varargin{i};
42 if (isa(index, 'cell'))
43 types{i} = '()';
44 elseif ischar(index)
45 types{i} = '.';
46 subs{i} = deblank(index); % deblank field name
47 else
48 error(message('MATLAB:setfield:InvalidType'));
49 end
50 end
51
52 % Perform assignment
53 try
54 s = builtin('subsasgn', s, struct('type',types,'subs',subs), varargin{end});
55 catch exception
56 exceptionToThrow = MException('MATLAB:setfield', '%s', exception.message);
57 throw(exceptionToThrow);
58 end

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