This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
cell.setdiff>cellsetdiffR2012asubfunction12
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
144
[varargout{1:nlhs}] = celluniq...
60.010 s50.0%
142
[varargout{1:nlhs}] = celluniq...
60.010 s50.0%
151
end
120 s0%
150
end
120 s0%
143
elseif flaginds(7) % trailing ...
60 s0%
All other lines  0 s0%
Totals  0.020 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
cell.unique>celluniqueR2012asubfunction120.020 s100.0%
Self time (built-ins, overhead, etc.)  0 s0%
Totals  0.020 s100% 
Code Analyzer results
Line numberMessage
Coverage results
Show coverage for parent directory
Total lines in function151
Non-code lines (comments, blank lines)88
Code lines (lines that can run)63
Code lines that did run32
Code lines that did not run31
Coverage (did run/can run)50.79 %
Function listing
time 
calls 
 line
   1 
function varargout = unique(varargin)
   2 
%UNIQUE Set unique.
   3 
%   C = UNIQUE(A) for the array A returns the same values as in A but with 
   4 
%   no repetitions. C will be sorted.    
   5 
%  
   6 
%   C = UNIQUE(A,'rows') for the matrix A returns the unique rows of A.
   7 
%   The rows of the matrix C will be in sorted order.
   8 
%  
   9 
%   [C,IA,IC] = UNIQUE(A) also returns index vectors IA and IC such that
  10 
%   C = A(IA) and A = C(IC).  
  11 
%  
  12 
%   [C,IA,IC] = UNIQUE(A,'rows') also returns index vectors IA and IC such
  13 
%   that C = A(IA,:) and A = C(IC,:). 
  14 
%  
  15 
%   [C,IA,IC] = UNIQUE(A,OCCURRENCE) and
  16 
%   [C,IA,IC] = UNIQUE(A,'rows',OCCURRENCE) specify which index is returned
  17 
%   in IA in the case of repeated values (or rows) in A. The default value
  18 
%   is OCCURENCE = 'first', which returns the index of the first occurrence  
  19 
%   of each repeated value (or row) in A, while OCCURRENCE = 'last' returns 
  20 
%   the index of the last occurrence of each repeated value (or row) in A.
  21 
%  
  22 
%   [C,IA,IC] = UNIQUE(A,'stable') returns the values of C in the same order
  23 
%   that they appear in A, while [C,IA,IC] = UNIQUE(A,'sorted') returns the
  24 
%   values of C in sorted order. If A is a row vector, then C will be a row
  25 
%   vector as well, otherwise C will be a column vector. IA and IC are
  26 
%   column vectors. If there are repeated values in A, then IA returns the
  27 
%   index of the first occurrence of each repeated value.
  28 
% 
  29 
%   [C,IA,IC] = UNIQUE(A,'rows','stable') returns the rows of C in the same
  30 
%   order that they appear in A, while [C,IA,IC] = UNIQUE(A,'rows','sorted')
  31 
%   returns the rows of C in sorted order.
  32 
% 
  33 
%   The behavior of UNIQUE has changed.  This includes:
  34 
%     -	occurrence of indices in IA and IC switched from last to first
  35 
%     -	IA and IC will always be column index vectors
  36 
% 
  37 
%   If this change in behavior has adversely affected your code, you may 
  38 
%   preserve the previous behavior with:
  39 
% 
  40 
%        [C,IA,IC] = UNIQUE(A,'legacy')
  41 
%        [C,IA,IC] = UNIQUE(A,'rows','legacy') 
  42 
%        [C,IA,IC] = UNIQUE(A,OCCURRENCE,'legacy')
  43 
%        [C,IA,IC] = UNIQUE(A,'rows',OCCURRENCE,'legacy')
  44 
%
  45 
%   Examples:
  46 
%
  47 
%       a = [9 9 9 9 9 9 8 8 8 8 7 7 7 6 6 6 5 5 4 2 1]
  48 
%
  49 
%       [c1,ia1,ic1] = unique(a)
  50 
%       % returns
  51 
%       c1 = [1 2 4 5 6 7 8 9]
  52 
%       ia1 = [21 20 19 17 14 11 7 1]'
  53 
%       ic1 = [8 8 8 8 8 8 7 7 7 7 6 6 6 5 5 5 4 4 3 2 1]'
  54 
%
  55 
%       [c2,ia2,ic2] = unique(a,'stable')
  56 
%       % returns
  57 
%       c2 = [9 8 7 6 5 4 2 1]
  58 
%       ia2 = [1 7 11 14 17 19 20 21]'
  59 
%       ic2 = [1 1 1 1 1 1 2 2 2 2 3 3 3 4 4 4 5 5 6 7 8]'
  60 
%
  61 
%       c = unique([1 NaN NaN 2])
  62 
%       % NaNs compare as not equal, so this returns
  63 
%       c = [1 2 NaN NaN]
  64 
%
  65 
%   Class support for input A:
  66 
%      - logical, char, all numeric classes
  67 
%      - cell arrays of strings
  68 
%      -- 'rows' option is not supported for cell arrays
  69 
%      - objects with methods SORT (SORTROWS for the 'rows' option) and NE
  70 
%      -- including heterogeneous arrays
  71 
%
  72 
%   See also UNION, INTERSECT, SETDIFF, SETXOR, ISMEMBER, SORT, SORTROWS.
  73 

  74 
%   Copyright 1984-2013 The MathWorks, Inc.
  75 

  76 
% Determine the number of outputs requested.
     12 
  77 
if nargout == 0 
  78 
    nlhs = 1;
     12 
  79 
else 
     12 
  80 
    nlhs = nargout; 
     12 
  81 
end 
  82 

     12 
  83 
narginchk(1,4); 
     12 
  84 
if ~iscellstr(varargin{1}) 
  85 
    error(message('MATLAB:UNIQUE:InputClass'));
  86 
end
     12 
  87 
nrhs = nargin; 
     12 
  88 
if nrhs == 1 
  89 
    [varargout{1:nlhs}] = celluniqueR2012a(varargin{:});
     12 
  90 
else 
  91 
    % acceptable combinations, with optional inputs denoted in []
  92 
    % unique(A, ['rows'], ['first'/'last'], ['legacy'/'R2012a']),
  93 
    % where the position of 'rows' and 'first'/'last' may be reversed
  94 
    % unique(A, ['rows'], ['sorted'/'stable']),
  95 
    % where the position of 'rows' and 'sorted'/'stable' may be reversed
     12 
  96 
    nflagvals = 7; 
     12 
  97 
    flagvals = {'rows' 'first' 'last' 'sorted' 'stable' 'legacy' 'R2012a'}; 
  98 
    % When a flag is found, note the index into varargin where it was found
     12 
  99 
    flaginds = zeros(1,nflagvals); 
     12 
 100 
    for i = 2:nrhs 
     12 
 101 
        flag = varargin{i}; 
     12 
 102 
        foundflag = strcmpi(flag,flagvals); 
     12 
 103 
        if ~any(foundflag) 
 104 
            if ischar(flag)
 105 
                error(message('MATLAB:UNIQUE:UnknownFlag',flag));
 106 
            else
 107 
                error(message('MATLAB:UNIQUE:UnknownInput'));
 108 
            end
 109 
        end
 110 
        % Only 1 occurrence of each allowed flag value
     12 
 111 
        if flaginds(foundflag) 
 112 
            error(message('MATLAB:UNIQUE:RepeatedFlag',flag));
 113 
        end
     12 
 114 
        flaginds(foundflag) = i; 
     12 
 115 
    end 
 116 
    
 117 
    % Only 1 of each of the paired flags
     12 
 118 
    if flaginds(2) && flaginds(3) 
 119 
        error(message('MATLAB:UNIQUE:OccurrenceConflict'))
 120 
    end
     12 
 121 
    if flaginds(4) && flaginds(5) 
 122 
        error(message('MATLAB:UNIQUE:SetOrderConflict'))
 123 
    end
     12 
 124 
    if flaginds(6) && flaginds(7) 
 125 
        error(message('MATLAB:UNIQUE:BehaviorConflict'))
 126 
    end
 127 
    % 'legacy' and 'R2012a' flags must be trailing
     12 
 128 
    if flaginds(6) && flaginds(6)~=nrhs 
 129 
        error(message('MATLAB:UNIQUE:LegacyTrailing'))
 130 
    end
     12 
 131 
    if flaginds(7) && flaginds(7)~=nrhs 
 132 
        error(message('MATLAB:UNIQUE:R2012aTrailing'))
 133 
    end
 134 
    
     12 
 135 
    if flaginds(4) || flaginds(5) % 'stable'/'sorted' specified 
      6 
 136 
        if flaginds(2) || flaginds(3) % does not combine with 'first'/'last' 
 137 
            error(message('MATLAB:UNIQUE:SetOrderOccurrence'))
 138 
        end
      6 
 139 
        if flaginds(6) || flaginds(7) % does not combine with 'legacy'/'R2012a' 
 140 
            error(message('MATLAB:UNIQUE:SetOrderBehavior'))
 141 
        end
  0.01 
      6 
 142 
        [varargout{1:nlhs}] = celluniqueR2012a(varargin{1},logical(flaginds(1:5))); 
      6 
 143 
    elseif flaginds(7) % trailing 'R2012a' specified 
  0.01 
      6 
 144 
        [varargout{1:nlhs}] = celluniqueR2012a(varargin{1},logical(flaginds(1:5))); 
 145 
    elseif flaginds(6) % trailing 'legacy' specified
 146 
        [varargout{1:nlhs}] = celluniquelegacy(varargin{1},logical(flaginds(1:3)));
 147 
    else % 'R2012a' (default behavior, to be changed to 'R2012a' in future)
 148 
        [varargout{1:nlhs}] = celluniqueR2012a(varargin{1},logical(flaginds(1:5)));
 149 
    end
     12 
 150 
end 
     12 
 151 
end 

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