MATLAB Commands for Set Operations

SET_THEORY is a MATLAB library which demonstrates how set-theoretic operations can be carried out, primarily using built-in MATLAB commands.

We assume that a set is represented by a strictly ascending sequence of positive integers. We might think of a universal set U = 1 : N in cases where all our subsets will have elements between 1 and N.

Set theoretic operations include


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


SET_THEORY is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

COMBO, a MATLAB library which handles combinatorial problems, by Kreher and Stinson;

SUBSET, a MATLAB library which ranks, unranks, and generates random subsets, combinations, permutations, and so on;


  1. Charles Pinter,
    Set Theory,
    Addison-Wesley, 1971,
    LC: QA248.P55.

Source Code:

Examples and Tests:

You can go up one level to the MATLAB source codes.

Last revised on 14 August 2011.