2670
|
1 @c Copyright (C) 1996, 1997 John W. Eaton |
2333
|
2 @c This is part of the Octave manual. |
|
3 @c For copying conditions, see the file gpl.texi. |
|
4 |
2653
|
5 @node Sets, Polynomial Manipulations, Statistics, Top |
2333
|
6 @chapter Sets |
|
7 |
|
8 Octave has a limited set of functions for managing sets of data, where a |
|
9 set is defined as a collection unique elements. |
|
10 |
2449
|
11 @deftypefn {Function File} {} create_set (@var{x}) |
2768
|
12 Return a row vector containing the unique values in @var{x}, sorted in |
|
13 ascending order. For example, |
2449
|
14 |
|
15 @example |
2689
|
16 @group |
2449
|
17 create_set ([ 1, 2; 3, 4; 4, 2 ]) |
2689
|
18 @result{} [ 1, 2, 3, 4 ] |
|
19 @end group |
2449
|
20 @end example |
|
21 @end deftypefn |
|
22 |
|
23 @deftypefn {Function File} {} union (@var{x}, @var{y}) |
|
24 Return the set of elements that are in either of the sets @var{x} and |
|
25 @var{y}. For example, |
|
26 |
|
27 @example |
2689
|
28 @group |
2745
|
29 union ([ 1, 2, 4 ], [ 2, 3, 5 ]) |
|
30 @result{} [ 1, 2, 3, 4, 5 ] |
2689
|
31 @end group |
2449
|
32 @end example |
|
33 @end deftypefn |
|
34 |
|
35 @deftypefn {Function File} {} intersection (@var{x}, @var{y}) |
|
36 Return the set of elements that are in both sets @var{x} and @var{y}. |
2689
|
37 For example, |
|
38 |
|
39 @example |
|
40 @group |
|
41 intersection ([ 1, 2, 3 ], [ 2, 3, 5 ]) |
|
42 @result{} [ 2, 3 ] |
|
43 @end group |
|
44 @end example |
2449
|
45 @end deftypefn |
2333
|
46 |
2449
|
47 @deftypefn {Function File} {} complement (@var{x}, @var{y}) |
2768
|
48 Return the elements of set @var{y} that are not in set @var{x}. For |
2449
|
49 example, |
|
50 |
|
51 @example |
2689
|
52 @group |
2449
|
53 complement ([ 1, 2, 3 ], [ 2, 3, 5 ]) |
2689
|
54 @result{} 5 |
|
55 @end group |
2449
|
56 @end example |
|
57 @end deftypefn |