This is a static copy of a profile report

Home

cell.setdiff (Calls: 10, Time: 0.024 s)
Generated 16-Jul-2020 17:09:35 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/ops/@cell/setdiff.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...natePrintPath>LocalRestoreOldPropssubfunction10
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
83
[varargout{1:nlhs}] = cellsetd...
100.023 s95.5%
82
if nrhs == 2
100.000 s0.8%
138
end
100.000 s0.1%
80
narginchk(2,4);
100.000 s0.0%
74
if nargout == 0
100.000 s0.0%
All other lines  0.001 s3.6%
Totals  0.024 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
cell.setdiff>cellsetdiffR2012asubfunction100.021 s88.9%
Self time (built-ins, overhead, etc.)  0.003 s11.1%
Totals  0.024 s100% 
Code Analyzer results
Line numberMessage
Coverage results
Show coverage for parent directory
Total lines in function138
Non-code lines (comments, blank lines)84
Code lines (lines that can run)54
Code lines that did run10
Code lines that did not run44
Coverage (did run/can run)18.52 %
Function listing
time 
Calls 
 line
   1 
function varargout = setdiff(varargin)
   2 
%SETDIFF Set difference.
   3 
%   C = SETDIFF(A,B) for vectors A and B, returns the values in A that 
   4 
%   are not in B with no repetitions. C will be sorted.
   5 
%
   6 
%   C = SETDIFF(A,B,'rows') for matrices A and B with the same number of
   7 
%   columns, returns the rows from A that are not in B. The rows of the
   8 
%   matrix C will be in sorted order.
   9 
%
  10 
%   [C,IA] = SETDIFF(A,B) also returns an index vector IA such that
  11 
%   C = A(IA). If there are repeated values in A that are not in B, then
  12 
%   the index of the first occurrence of each repeated value is returned.
  13 
%
  14 
%   [C,IA] = SETDIFF(A,B,'rows') also returns an index vector IA such that
  15 
%   C = A(IA,:).
  16 
%
  17 
%   [C,IA] = SETDIFF(A,B,'stable') for arrays A and B, returns the values
  18 
%   of C in the order that they appear in A.
  19 
%   [C,IA] = SETDIFF(A,B,'sorted') returns the values of C in sorted order.
  20 
%   If A is a row vector, then C will be a row vector as well, otherwise C
  21 
%   will be a column vector. IA is a column vector. If there are repeated
  22 
%   values in A that are not in B, then the index of the first occurrence of
  23 
%   each repeated value is returned.
  24 
%
  25 
%   [C,IA] = SETDIFF(A,B,'rows','stable') returns the rows of C in the
  26 
%   same order that they appear in A.
  27 
%   [C,IA] = SETDIFF(A,B,'rows','sorted') returns the rows of C in sorted
  28 
%   order.
  29 
%
  30 
%   The behavior of SETDIFF has changed.  This includes:
  31 
%     -	occurrence of indices in IA switched from last to first
  32 
%     -	orientation of vector C
  33 
%     -	IA will always be a column index vector
  34 
%     -	tighter restrictions on combinations of classes
  35 
% 
  36 
%   If this change in behavior has adversely affected your code, you may 
  37 
%   preserve the previous behavior with:
  38 
% 
  39 
%      [C,IA] = SETDIFF(A,B,'legacy')
  40 
%      [C,IA] = SETDIFF(A,B,'rows','legacy')
  41 
%
  42 
%   Examples:
  43 
%
  44 
%      a = [9 9 9 9 9 9 8 8 8 8 7 7 7 6 6 6 5 5 4 2 1]
  45 
%      b = [1 1 1 3 3 3 3 3 4 4 4 4 4 10 10 10]
  46 
%
  47 
%      [c1,ia1] = setdiff(a,b)
  48 
%      % returns
  49 
%      c1 = [2 5 6 7 8 9]
  50 
%      ia1 = [20 17 14 11 7 1]'
  51 
%
  52 
%      [c2,ia2] = setdiff(a,b,'stable')
  53 
%      % returns
  54 
%      c2 = [9 8 7 6 5 2]
  55 
%      ia2 = [1 7 11 14 17 20]'
  56 
%
  57 
%      c = setdiff([1 NaN 2 3],[3 4 NaN 1])
  58 
%      % NaNs compare as not equal, so this returns
  59 
%      c = [2 NaN]
  60 
%
  61 
%   Class support for inputs A and B, where A and B must be of the same
  62 
%   class unless stated otherwise:
  63 
%      - logical, char, all numeric classes (may combine with double arrays)
  64 
%      - cell arrays of strings (may combine with char arrays)
  65 
%      -- 'rows' option is not supported for cell arrays
  66 
%      - objects with methods SORT (SORTROWS for the 'rows' option), EQ and NE
  67 
%      -- including heterogeneous arrays derived from the same root class
  68 
%
  69 
%   See also UNIQUE, UNION, INTERSECT, SETXOR, ISMEMBER, SORT, SORTROWS.
  70 

  71 
%   Copyright 1984-2017 The MathWorks, Inc. 
  72 

  73 
% Determine the number of outputs requested.
< 0.001 
     10 
  74
if nargout == 0 
  75 
    nlhs = 1;
< 0.001 
     10 
  76
else 
< 0.001 
     10 
  77
    nlhs = nargout; 
< 0.001 
     10 
  78
end 
  79 

< 0.001 
     10 
  80
narginchk(2,4); 
< 0.001 
     10 
  81
nrhs = nargin; 
< 0.001 
     10 
  82
if nrhs == 2 
  0.023 
     10 
  83
    [varargout{1:nlhs}] = cellsetdiffR2012a(varargin{:});     
  84 
else
  85 
    % acceptable combinations, with optional inputs denoted in []
  86 
    % setdiff(A,B, ['rows'], ['legacy'/'R2012a']),
  87 
    % setdiff(A,B, ['rows'], ['sorted'/'stable']),
  88 
    % where the position of 'rows' and 'sorted'/'stable' may be reversed
  89 
    nflagvals = 5;
  90 
    flagvals = ["rows" "sorted" "stable" "legacy" "R2012a"];
  91 
    % When a flag is found, note the index into varargin where it was found
  92 
    flaginds = zeros(1,nflagvals);
  93 
    for i = 3:nrhs
  94 
        flag = varargin{i};
  95 
        foundflag = matlab.internal.math.partialMatchString(flag,flagvals);
  96 
        if ~any(foundflag)
  97 
            if ischar(flag)
  98 
                error(message('MATLAB:SETDIFF:UnknownFlag',flag));
  99 
            else
 100 
                error(message('MATLAB:SETDIFF:UnknownInput'));
 101 
            end
 102 
        end
 103 
        % Only 1 occurrence of each allowed flag value
 104 
        if flaginds(foundflag)
 105 
            error(message('MATLAB:SETDIFF:RepeatedFlag',flag));
 106 
        end
 107 
        flaginds(foundflag) = i;
 108 
    end
 109 
    
 110 
    % Only 1 of each of the paired flags
 111 
    if flaginds(2) && flaginds(3)
 112 
        error(message('MATLAB:SETDIFF:SetOrderConflict'))
 113 
    end
 114 
    if flaginds(4) && flaginds(5)
 115 
        error(message('MATLAB:SETDIFF:BehaviorConflict'))
 116 
    end
 117 
    % 'legacy' and 'R2012a' flags must be trailing
 118 
    if flaginds(4) && flaginds(4)~=nrhs
 119 
        error(message('MATLAB:SETDIFF:LegacyTrailing'))
 120 
    end
 121 
    if flaginds(5) && flaginds(5)~=nrhs
 122 
        error(message('MATLAB:SETDIFF:R2012aTrailing'))
 123 
    end
 124 
    
 125 
    if flaginds(2) || flaginds(3) % 'stable'/'sorted' specified
 126 
        if flaginds(4) || flaginds(5) % does not combine with 'legacy'/'R2012a'
 127 
            error(message('MATLAB:SETDIFF:SetOrderBehavior'))
 128 
        end
 129 
        [varargout{1:nlhs}] = cellsetdiffR2012a(varargin{1:2},logical(flaginds(1:3)));
 130 
    elseif flaginds(5) % trailing 'R2012a' specified
 131 
        [varargout{1:nlhs}] = cellsetdiffR2012a(varargin{1:2},logical(flaginds(1:3)));
 132 
    elseif flaginds(4) % trailing 'legacy' specified
 133 
        [varargout{1:nlhs}] = cellsetdifflegacy(varargin{1:2},logical(flaginds(1)));
 134 
    else % 'R2012a' (default behavior)
 135 
        [varargout{1:nlhs}] = cellsetdiffR2012a(varargin{1:2},logical(flaginds(1:3)));
 136 
    end
< 0.001 
     10 
 137
end 
< 0.001 
     10 
 138
end 

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