This is a static copy of a profile report

Home

rmfield (12 calls, 0.000 sec)
Generated 14-Nov-2016 07:47:21 using cpu time.
function in file /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/datatypes/rmfield.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...gt;LocalRestoreInvertedColorsIfNeededsubfunction6
...intPath>LocalRestoreSelectionStatesubfunction6
Lines where the most time was spent
No measurable time spent in this function

Line NumberCodeCallsTotal Time% TimeTime Plot
60
t = cell2struct(reshape(c(idxk...
120 s0%
57
newsizeofarray(1) = sizeofarra...
120 s0%
54
newsizeofarray = sizeofarray;
120 s0%
53
sizeofarray = size(c);
120 s0%
50
c = struct2cell(s);
120 s0%
All other lines  0 s0%
Totals  0 s0% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
cellstrfunction120 s0%
Self time (built-ins, overhead, etc.)  0 s0%
Totals  0 s0% 
Code Analyzer results
Line numberMessage
39The variable 'idxremove' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
Show coverage for parent directory
Total lines in function60
Non-code lines (comments, blank lines)31
Code lines (lines that can run)29
Code lines that did run20
Code lines that did not run9
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 

  14 
%--------------------------------------------------------------------------------------------
  15 
% handle input arguments
     12 
  16 
if ~isa(s,'struct')  
  17 
    error(message('MATLAB:rmfield:Arg1NotStructArray')); 
  18 
end
     12 
  19 
if ~ischar(field) && ~iscellstr(field) 
  20 
   error(message('MATLAB:rmfield:FieldnamesNotStrings'));
     12 
  21 
elseif ischar(field) 
     12 
  22 
   field = cellstr(field);  
     12 
  23 
end 
  24 

  25 
% get fieldnames of struct
     12 
  26 
f = fieldnames(s); 
  27 

  28 
% Determine which fieldnames to delete.
     12 
  29 
idxremove = []; 
     12 
  30 
for i=1:length(field) 
     12 
  31 
  j = find(strcmp(field{i},f) == true); 
     12 
  32 
  if isempty(j) 
  33 
    if length(field{i}) > namelengthmax
  34 
      error(message('MATLAB:rmfield:FieldnameTooLong', field{ i }));
  35 
    else
  36 
      error(message('MATLAB:rmfield:InvalidFieldname', field{ i }));
  37 
    end
  38 
  end
     12 
  39 
  idxremove = [idxremove;j]; 
     12 
  40 
end 
  41 

  42 
% set indices of fields to keep
     12 
  43 
idxkeep = 1:length(f); 
     12 
  44 
idxkeep(idxremove) = []; 
  45 

  46 
% remove the specified fieldnames from the list of fieldnames.
     12 
  47 
f(idxremove,:) = []; 
  48 

  49 
% convert struct to cell array
     12 
  50 
c = struct2cell(s); 
  51 

  52 
% find size of cell array
     12 
  53 
sizeofarray = size(c); 
     12 
  54 
newsizeofarray = sizeofarray; 
  55 

  56 
% adjust size for fields to be removed
     12 
  57 
newsizeofarray(1) = sizeofarray(1) - length(idxremove); 
  58 

  59 
% rebuild struct
     12 
  60 
t = cell2struct(reshape(c(idxkeep,:),newsizeofarray),f); 

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