This is a static copy of a profile reportHome
rmfield (97 calls, 0.033 sec)
Generated 05-Aug-2011 13:00:27 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/datatypes/rmfield.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 |
48 | f(idxremove,:) = []; | 97 | 0.011 s | 33.3% |  |
44 | idxkeep = 1:length(f); | 97 | 0.011 s | 33.3% |  |
20 | if ~ischar(field) && ~... | 97 | 0.011 s | 33.3% |  |
61 | t = cell2struct(reshape(c(idxk... | 97 | 0 s | 0% |  |
58 | newsizeofarray(1) = sizeofarra... | 97 | 0 s | 0% |  |
All other lines | | | 0 s | 0% |  |
Totals | | | 0.033 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
iscellstr | function | 90 | 0.011 s | 33.3% |  |
cellstr | function | 7 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0.022 s | 66.7% |  |
Totals | | | 0.033 s | 100% | |
Code Analyzer results
Line number | Message |
40 | The variable 'idxremove' appears to change size on every loop iteration. Consider preallocating for speed. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 61 |
Non-code lines (comments, blank lines) | 32 |
Code lines (lines that can run) | 29 |
Code lines that did run | 20 |
Code lines that did not run | 9 |
Coverage (did run/can run) | 68.97 % |
Function listing
time calls line
1 function t = rmfield(s,field)
2 %RMFIELD Remove fields from a structure array.
3 % S = RMFIELD(S,'field') removes the specified field from the
4 % m x n structure array S. The size of input S is preserved.
5 %
6 % S = RMFIELD(S,FIELDS) removes more than one field at a time
7 % when FIELDS is a character array or cell array of strings. The
8 % changed structure is returned. The size of input S is preserved.
9 %
10 % See also SETFIELD, GETFIELD, ISFIELD, FIELDNAMES.
11
12 % Copyright 1984-2008 The MathWorks, Inc.
13 % $Revision: 1.25.4.6 $ $Date: 2010/08/23 23:07:52 $
14
15 %--------------------------------------------------------------------------------------------
16 % handle input arguments
97 17 if ~isa(s,'struct')
18 error(message('MATLAB:rmfield:Arg1NotStructArray'));
19 end
0.01 97 20 if ~ischar(field) && ~iscellstr(field)
21 error(message('MATLAB:rmfield:FieldnamesNotStrings'));
97 22 elseif ischar(field)
7 23 field = cellstr(field);
7 24 end
25
26 % get fieldnames of struct
97 27 f = fieldnames(s);
28
29 % Determine which fieldnames to delete.
97 30 idxremove = [];
97 31 for i=1:length(field)
97 32 j = find(strcmp(field{i},f) == true);
97 33 if isempty(j)
34 if length(field{i}) > namelengthmax
35 error(message('MATLAB:rmfield:FieldnameTooLong', field{ i }));
36 else
37 error(message('MATLAB:rmfield:InvalidFieldname', field{ i }));
38 end
39 end
97 40 idxremove = [idxremove;j];
97 41 end
42
43 % set indices of fields to keep
0.01 97 44 idxkeep = 1:length(f);
97 45 idxkeep(idxremove) = [];
46
47 % remove the specified fieldnames from the list of fieldnames.
0.01 97 48 f(idxremove,:) = [];
49
50 % convert struct to cell array
97 51 c = struct2cell(s);
52
53 % find size of cell array
97 54 sizeofarray = size(c);
97 55 newsizeofarray = sizeofarray;
56
57 % adjust size for fields to be removed
97 58 newsizeofarray(1) = sizeofarray(1) - length(idxremove);
59
60 % rebuild struct
97 61 t = cell2struct(reshape(c(idxkeep,:),newsizeofarray),f);
Other subfunctions in this file are not included in this listing.