Next: , Previous: Financial Functions, Up: Top


28 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 ]
     
     
     
See also: union, intersection, complement.

— Function File: ismember (A, S)

Return a matrix the same shape as A which has 1 if A(i,j) is in S or 0 if it isn't.

     
     
See also: unique, union, intersection, setxor, setdiff.

— Function File: unique (x)

Return the unique elements of x, sorted in ascending order. If x is a row vector, return a row vector, but if x is a column vector or a matrix return a column vector. — Function File: unique (A, 'rows')

Return the unique rows of A, sorted in ascending order. — Function File: [y, i, j] = unique (x)

Return index vectors i and j such that x(i)==y and y(j)==x.

     
     
See also: union, intersect, setdiff, setxor, ismember.

— 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 ]
     
     
     
See also: create_set, intersection, complement.

— Function File: intersect (a, b)
— Function File: [c, ia, ib] = intersect (a, b)

Return the elements in both a and b, sorted in ascending order. If a and b are both column vectors return a column vector, otherwise return a row vector.

Return index vectors ia and ib such that a(ia)==c and b(ib)==c.


See also: unique, union, setxor, setdiff, ismember.

— 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
     
     
     
See also: create_set, union, intersection.

— Function File: setdiff (a, b)
— Function File: setdiff (a, b, "rows")

Return the elements in a that are not in b, sorted in ascending order. If a and b are both column vectors return a column vector, otherwise return a row vector.

Given the optional third argument `"rows"', return the rows in a that are not in b, sorted in ascending order by rows.

     
     
See also: unique, union, intersect, setxor, ismember.

— Function File: setxor (a, b)

Return the elements exclusive to a or b, sorted in ascending order. If a and b are both column vectors return a column vector, otherwise return a row vector.

     
     
See also: unique, union, intersect, setdiff, ismember.