Mercurial > hg > octave-nkf
annotate scripts/deprecated/create_set.m @ 12749:e7cc2d4a6db3 stable
Fix range of sigma in normal distribution to exclude 0.
* normcdf.m, normpdf.m: Correct 's >= 0' to 's > 0'.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 16 Jun 2011 21:05:10 -0700 |
parents | a17269b1148f |
children |
rev | line source |
---|---|
12728
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 ## Copyright (C) 1994-2011 John W. Eaton |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 ## |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 ## |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 ## your option) any later version. |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 ## |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 ## General Public License for more details. |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 ## |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 ## @deftypefn {Function File} {} create_set (@var{x}) |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 ## @deftypefnx {Function File} {} create_set (@var{x}, "rows") |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 ## This function has been deprecated. Use unique instead. |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 ## @end deftypefn |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 ## Return a row vector containing the unique values in @var{x}, sorted in |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 ## ascending order. For example, |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 ## |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 ## @example |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 ## @group |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 ## create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ]) |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 ## @result{} [ 1, 2, 3, 4 ] |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 ## @end group |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 ## @end example |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 ## |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 ## If the optional second input argument is the string "rows" each row of |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 ## the matrix @var{x} will be considered an element of set. For example, |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 ## @example |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 ## @group |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 ## create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ], "rows") |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 ## @result{} 1 2 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 ## 3 4 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 ## 4 2 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 ## @end group |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 ## @end example |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 ## @seealso{union, intersect, complement, unique} |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 ## Author: jwe |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 ## Deprecated in version 3.2 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 function y = create_set (x, rows_opt) |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 persistent warned = false; |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 if (! warned) |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 warned = true; |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 warning ("Octave:deprecated-function", |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 "create_set is obsolete and will be removed from a future version of Octave, please use unique instead"); |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 endif |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 if (nargin < 1 || nargin > 2) |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 print_usage (); |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 endif |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 if (nargin == 1) |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 y = unique (x)(:)'; |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 elseif (strcmpi (rows_opt, "rows")) |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 y = unique (x, "rows"); |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 else |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 error ("create_set: expecting \"rows\" as second argument"); |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 endif |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 endfunction |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 %!assert(all (all (create_set ([1, 2, 3, 4, 2, 4]) == [1, 2, 3, 4]))); |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 %!assert(all (all (create_set ([1, 2; 3, 4; 2, 4]) == [1, 2, 3, 4]))); |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 %!assert(all (all (create_set ([1; 2; 3; 4; 2; 4]) == [1, 2, 3, 4]))); |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 %!assert(isempty (create_set ([]))); |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 %!error create_set (1, 2); |
a17269b1148f
maint: undo unintended change removing deprecated functions
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 |