1 ## Copyright (C) 1995-2012 Kurt Hornik
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} values (@var{x})
21 ## Return the different values in a column vector, arranged in ascending
24 ## As an example, @code{values([1, 2, 3, 1])} returns the vector
28 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
29 ## Description: Extract unique elements
31 ## Deprecated in version 3.4
33 function v = values (x)
35 persistent warned = false;
38 warning ("Octave:deprecated-function",
39 "values is obsolete and will be removed from a future version of Octave; please use unique instead");
47 error ("values: X must be a vector");
52 x = x(find(!isnan (x)));
54 x = reshape (x, n, 1);
56 v = s([1; (find (s(2:n) > s(1:n-1)) + 1)]);