view doc/interpreter/set.texi @ 2670:18192eea4973

[project @ 1997-02-13 18:29:53 by jwe]
author jwe
date Thu, 13 Feb 1997 18:34:06 +0000
parents e7908588548a
children 8c7955a8d49f
line wrap: on
line source

@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})
Given a matrix or vector of values, the function @code{create_set}
returns a row vector containing unique values, sorted in ascending
order.  For example,

@example
create_set ([ 1, 2; 3, 4; 4, 2 ])
@end example

@noindent
returns the vector

@example
[ 1, 2, 3, 4 ]
@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
union ([ 1, 2, 3 ], [ 2, 3, 5 ])
@end example

@noindent
returns the vector

@example
[ 1, 2, 5 ]
@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}.
@end deftypefn

@deftypefn {Function File} {} complement (@var{x}, @var{y})
Returns the elements of set @var{y} that are not in set @var{x}.  For
example,

@example
complement ([ 1, 2, 3 ], [ 2, 3, 5 ])
@end example

@noindent
returns the value @samp{5}.
@end deftypefn