Main Content

Set Operations

Unions, intersection, set membership

Set operations compare the elements in two sets to find commonalities or differences. In MATLAB®, the sets can be arrays of numbers, dates, times, tables, timetables, or text data.

Most set operations compare sets for exact equality, which can be problematic in the context of floating-point arithmetic. For that reason, the ismembertol and uniquetol functions are also available to perform comparisons with a tolerance.

Functions

intersectIntersection of two sets of data
ismemberFind set members of data
setdiffDifference of two sets of data
setxorExclusive OR of two sets of data
unionUnion of two sets of data
uniqueUnique values
ismembertolFind set members of data within tolerance
uniquetolUnique values within tolerance
joinCombine two tables or timetables by rows using key variables
innerjoinInner join between two tables or timetables
outerjoinOuter join between two tables or timetables

Topics