Mercurial > hg > octave-lyh
diff doc/interpreter/set.txi @ 3294:bfe1573bd2ae
[project @ 1999-10-19 10:06:07 by jwe]
author | jwe |
---|---|
date | Tue, 19 Oct 1999 10:08:42 +0000 |
parents | |
children | a4cd1e9d9962 |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/doc/interpreter/set.txi @@ -0,0 +1,57 @@ +@c Copyright (C) 1996, 1997 John W. Eaton +@c This is part of the Octave manual. +@c For copying conditions, see the file gpl.texi. + +@node Sets, Polynomial Manipulations, Statistics, Top +@chapter Sets + +Octave has a limited set of functions for managing sets of data, where a +set is defined as a collection unique elements. + +@deftypefn {Function File} {} create_set (@var{x}) +Return a row vector containing the unique values in @var{x}, sorted in +ascending order. For example, + +@example +@group +create_set ([ 1, 2; 3, 4; 4, 2 ]) + @result{} [ 1, 2, 3, 4 ] +@end group +@end example +@end deftypefn + +@deftypefn {Function File} {} union (@var{x}, @var{y}) +Return the set of elements that are in either of the sets @var{x} and +@var{y}. For example, + +@example +@group +union ([ 1, 2, 4 ], [ 2, 3, 5 ]) + @result{} [ 1, 2, 3, 4, 5 ] +@end group +@end example +@end deftypefn + +@deftypefn {Function File} {} intersection (@var{x}, @var{y}) +Return the set of elements that are in both sets @var{x} and @var{y}. +For example, + +@example +@group +intersection ([ 1, 2, 3 ], [ 2, 3, 5 ]) + @result{} [ 2, 3 ] +@end group +@end example +@end deftypefn + +@deftypefn {Function File} {} complement (@var{x}, @var{y}) +Return the elements of set @var{y} that are not in set @var{x}. For +example, + +@example +@group +complement ([ 1, 2, 3 ], [ 2, 3, 5 ]) + @result{} 5 +@end group +@end example +@end deftypefn