help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

==> unique


From: Daniel Heiserer
Subject: ==> unique
Date: Tue, 03 Nov 1998 08:54:14 +0100

Well,
better to think first than mail. I answered my question concerning 
unique by myself. Sorry.

If somebody is interested here is a m-file which is pretty fast.
---------------------------------------------------------------------
function b=unique(a)
% b=UNIQUE(a) remove doubled elements.
%       The UNIQUE command searches the input vector
%       and returns a vector which contains the
%       elements of the input vector sorted and
%       only once.
%
% See also SORT.

% $Id: unique.m,v 1.1 1998/11/03 07:48:43 daniel Exp $
% Author: Daniel Heiserer mailto:address@hidden

% make sure it is a vector and sorted
[row,col]=size(a);
if min([row,col]) > 1
        error('nargin 1 must be a vector not a matrix');
end
END=max([row,col]);
a=sort(a);
% 
b=a(find([1,a(2:END)-a(1:END-1)]));
---------------------------------------------------------------------

-- 
Mit freundlichen Gruessen
                                 Daniel Heiserer
-----
--------------------------------------------------------------
Dipl.-Pys. Daniel Heiserer, BMW AG, Knorrstrasse 147, 80788 Muenchen
Abteilung EK-20
Tel.: 089-382-21187, Fax.: 089-382-42820
mailto:address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]