view doc/interpreter/set.texi @ 2449:31d5588dbb61

[project @ 1996-10-30 22:58:44 by jwe]
author jwe
date Wed, 30 Oct 1996 23:00:41 +0000
parents b1a56412c385
children e7908588548a
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, Statistics, Signal Processing, 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