This is a static copy of a profile report

Home

cell.unique (3 calls, 0.011 sec)
Generated 05-Aug-2011 13:00:26 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/ops/@cell/unique.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
read_arcfunction1
plot_sourcesfunction1
calcTsysfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
67
isrow = ndims(a)==2 &&...
30.011 s100.0%
94
ndx = ndx(d);
30 s0%
91
pos(ndx) = pos;
30 s0%
85
pos = cumsum(localcat(1,d(1:en...
30 s0%
83
if order(1) == 'l' % 'last'
30 s0%
All other lines  0 s0%
Totals  0.011 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
cell.unique>localcatsubfunction60 s0%
iscellstrfunction30 s0%
Self time (built-ins, overhead, etc.)  0.011 s100.0%
Totals  0.011 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function94
Non-code lines (comments, blank lines)35
Code lines (lines that can run)59
Code lines that did run17
Code lines that did not run42
Coverage (did run/can run)28.81 %
Function listing
   time   calls  line
1 function [b,ndx,pos] = unique(a,flag1,flag2)
2 %UNIQUE Return unique set for a cell array of strings.
3 % UNIQUE(A) for the cell vector A returns the same strings as in A but
4 % with no repetitions. The output is also sorted.
5 %
6 % [B,I,J] = UNIQUE(A) also returns index vectors I and J such
7 % that B = A(I) and A = B(J) (or B = A(I,:) and A = B(J,:)).
8 %
9 % [B,I,J] = UNIQUE(A,'first') returns the vector I to index the
10 % first occurrence of each unique value in A. UNIQUE(A,'last'),
11 % the default, returns the vector I to index the last occurrence.
12 %
13 % See also UNION, INTERSECT, SETDIFF, SETXOR, ISMEMBER.
14
15 % Copyright 1984-2007 The MathWorks, Inc.
16 % $Revision: 1.12.4.8 $ $Date: 2010/08/23 23:11:37 $
17 % ----------------------------------------------------------------------------------------------------
3 18 flagvals = {'rows' 'first' 'last'};
3 19 if nargin > 1
20 options = strcmpi(flag1,flagvals);
21 if nargin > 2
22 options = options + strcmpi(flag2,flagvals);
23 if any(options > 1) || (options(2)+options(3) > 1)
24 error(message('MATLAB:CELL:UNIQUE:RepeatedFlag'));
25 end
26 end
27 if sum(options) < nargin-1
28 error(message('MATLAB:CELL:UNIQUE:UnknownFlag'));
29 end
30 if options(1) > 0
31 warning(message('MATLAB:CELL:UNIQUE:RowsFlagIgnored'));
32 end
33 if options(2) > 0
34 order = 'first';
35 else % if options(3) > 0 || sum(options(2:3) == 0)
36 order = 'last';
37 end
3 38 elseif nargin == 1
3 39 order = 'last';
40 else
41 error(message('MATLAB:UNIQUE:NotEnoughInputs'));
42 end
43
3 44 if ~iscellstr(a)
45 error(message('MATLAB:CELL:UNIQUE:InputClass'))
46 end
47
48 % check is input is a column vector with each element a single row text array.
3 49 if any(cellfun('size',a,1)>1)
50 error(message('MATLAB:CELL:UNIQUE:NotARowVector'))
51 end
52
53 % initialise output variables
3 54 if isempty(a)
55 if ~any(size(a))
56 b = {};
57 ndx = [];
58 pos = [];
59 else
60 b = cell(0, 1);
61 ndx = zeros(0,1);
62 pos = ndx;
63 end
64 return
65 end
66
0.01 3 67 isrow = ndims(a)==2 && size(a,1)==1 && size(a,2) ~= 1;
68
69 % first sort the rows of the cell array.
3 70 [b,ndx] = sort(a);
71
3 72 d = ~strcmp(b(1:end-1),b(2:end));
73
3 74 if order(1) == 'l' % 'last'
3 75 d = localcat(d, true, isrow);
76 else % order == 'first'
77 d = localcat(true, d, isrow); % First element is always a member of unique list.
78 end
79
80 % extract unique elements
3 81 b = b(d);
82
3 83 if order(1) == 'l' % 'last'
84 % create position index vector
3 85 pos = cumsum(localcat(1,d(1:end-1), isrow));
86 else % order == 'first'
87 % create position index vector
88 pos = cumsum(d);
89 end
90 % Re-reference POS to indexing of SORT.
3 91 pos(ndx) = pos;
92
93 % create index vector
3 94 ndx = ndx(d);

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