view doc/interpreter/set.texi @ 2653:e7908588548a

[project @ 1997-02-01 16:53:52 by jwe]
author jwe
date Sat, 01 Feb 1997 16:57:10 +0000
parents 31d5588dbb61
children 18192eea4973
line wrap: on
line source

@c Copyright (C) 1996 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