www.delorie.com/gnu/docs/octave/octave_159.html   search  
 
Buy GNU books!


GNU Octave

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

23. Sets

Octave has a limited set of functions for managing sets of data, where a set is defined as a collection unique elements.

Function File: create_set (x)
Return a row vector containing the unique values in x, sorted in ascending order. For example,

 
create_set ([ 1, 2; 3, 4; 4, 2 ])
     => [ 1, 2, 3, 4 ]

Function File: union (x, y)
Return the set of elements that are in either of the sets x and y. For example,

 
union ([ 1, 2, 4 ], [ 2, 3, 5 ])
     => [ 1, 2, 3, 4, 5 ]

Function File: intersection (x, y)
Return the set of elements that are in both sets x and y. For example,

 
intersection ([ 1, 2, 3 ], [ 2, 3, 5 ])
     => [ 2, 3 ]

Function File: complement (x, y)
Return the elements of set y that are not in set x. For example,

 
complement ([ 1, 2, 3 ], [ 2, 3, 5 ])
     => 5


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003