Mercurial > hg > octave-max
annotate scripts/deprecated/create_set.m @ 11587:c792872f8942
all script files: untabify and strip trailing whitespace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:35:29 -0500 |
parents | fd0a3ac60b0e |
children |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1994-2011 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
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. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
2303 | 18 |
3368 | 19 ## -*- texinfo -*- |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
20 ## @deftypefn {Function File} {} create_set (@var{x}) |
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
21 ## @deftypefnx {Function File} {} create_set (@var{x}, "rows") |
8887 | 22 ## This function has been deprecated. Use unique instead. |
23 ## @end deftypefn | |
24 | |
3368 | 25 ## Return a row vector containing the unique values in @var{x}, sorted in |
26 ## ascending order. For example, | |
3426 | 27 ## |
3368 | 28 ## @example |
29 ## @group | |
7344 | 30 ## create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ]) |
3368 | 31 ## @result{} [ 1, 2, 3, 4 ] |
32 ## @end group | |
33 ## @end example | |
7344 | 34 ## |
35 ## If the optional second input argument is the string "rows" each row of | |
36 ## the matrix @var{x} will be considered an element of set. For example, | |
37 ## @example | |
38 ## @group | |
39 ## create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ], "rows") | |
40 ## @result{} 1 2 | |
41 ## 3 4 | |
42 ## 4 2 | |
43 ## @end group | |
44 ## @end example | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7411
diff
changeset
|
45 ## @seealso{union, intersect, complement, unique} |
3368 | 46 |
2314 | 47 ## Author: jwe |
48 | |
8888
0c7b0049c023
mark create_set as deprecated in 3.2, not 3.0
John W. Eaton <jwe@octave.org>
parents:
8887
diff
changeset
|
49 ## Deprecated in version 3.2 |
8887 | 50 |
7344 | 51 function y = create_set (x, rows_opt) |
559 | 52 |
8887 | 53 persistent warned = false; |
54 if (! warned) | |
55 warned = true; | |
56 warning ("Octave:deprecated-function", | |
57 "create_set is obsolete and will be removed from a future version of Octave, please use unique instead"); | |
58 endif | |
59 | |
7344 | 60 if (nargin < 1 || nargin > 2) |
6046 | 61 print_usage (); |
559 | 62 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
63 |
7344 | 64 if (nargin == 1) |
8887 | 65 y = unique (x)(:)'; |
7344 | 66 elseif (strcmpi (rows_opt, "rows")) |
67 y = unique (x, "rows"); | |
559 | 68 else |
7344 | 69 error ("create_set: expecting \"rows\" as second argument"); |
559 | 70 endif |
2325 | 71 |
559 | 72 endfunction |
7411 | 73 |
8887 | 74 %!assert(all (all (create_set ([1, 2, 3, 4, 2, 4]) == [1, 2, 3, 4]))); |
7411 | 75 %!assert(all (all (create_set ([1, 2; 3, 4; 2, 4]) == [1, 2, 3, 4]))); |
76 %!assert(all (all (create_set ([1; 2; 3; 4; 2; 4]) == [1, 2, 3, 4]))); | |
77 %!assert(isempty (create_set ([]))); | |
78 %!error create_set (1, 2); | |
79 |