NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/matutil/unique5.m

Revision 495 (checked in by cbc, 11 years ago)

Initial import of Stark code.

Line 
1
2 function [b] = unique(a)
3 %UNIQUE Set unique.
4 %   UNIQUE(A) for the vector A returns the same values as in A but
5 %   with no repetitions.  A will be also be sorted.  A can be a cell
6 %   array of strings.
7 %
8 %   Based on Matlab 5.0 compatible code, reworked by Catherine Edwards
9 %   for compatibility with Matlab v4
10 %
11
12 %   Cell array implementation in @cell/unique.m
13
14 if isempty(a), b = a; return, end
15
16
17   rowvec = size(a,1)==1;
18   [b,ndx] = sort(a(:));
19   % d indicates the location of matching entries
20   n=length(b);
21   d = b((1:n-1)')==b((2:n)');
22   n = length(a);
23
24 test=find(d==0);
25 b=[b(test); b(length(b))];
26
27 if rowvec,
28   b = b.';
29   ndx = ndx.';
30 end
31
32 end
Note: See TracBrowser for help on using the browser.