This is a static copy of a profile report

Home

setfield (78 calls, 0.011 sec)
Generated 05-Aug-2011 13:03:48 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/datatypes/setfield.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
structcutfunction78
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
26
if (isempty(varargin) || lengt...
780.011 s100.0%
35
return
780 s0%
34
s.(deblank(strField)) = vararg...
780 s0%
33
if (arglen==2)
780 s0%
32
strField = varargin{1};
780 s0%
All other lines  0 s0%
Totals  0.011 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.01 78 26 if (isempty(varargin) || length(varargin) < 2)
27 error(message('MATLAB:setfield:InsufficientInputs'));
28 end
29
30 % The most common case
78 31 arglen = length(varargin);
78 32 strField = varargin{1};
78 33 if (arglen==2)
78 34 s.(deblank(strField)) = varargin{end};
78 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.