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 are arrays of numbers, dates, times, 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

intersectSet intersection of two arrays
ismemberArray elements that are members of set array
setdiffSet difference of two arrays
setxorSet exclusive OR of two arrays
unionSet union of two arrays
uniqueUnique values in array
ismembertolMembers of set 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