intersect
Intersection of two sets of data
Syntax
Description
returns the data common to both C
= intersect(A,B
)A
and B
,
with no repetitions. C
is in sorted order.
If
A
andB
are tables or timetables, thenintersect
returns the set of rows common to both tables. For timetables,intersect
takes row times into account to determine equality, and sorts the output timetableC
by row times.
and
C
= intersect(A,B
,___,'rows')
treat each row of C
= intersect(A,B
,'rows',___)A
and each row of B
as
single entities and return the rows common to both A
and
B
, with no repetitions. You must specify
A
and B
and optionally can specify
setOrder
.
The 'rows'
option does not support cell arrays, unless one
of the inputs is either a categorical array or a datetime array.
Examples
Input Arguments
Output Arguments
Tips
To find the intersection with respect to a subset of variables from a table or timetable, you can use column subscripting. For example, you can use
intersect(A(:,
, wherevars
),B(:,vars
))vars
is a positive integer, a vector of positive integers, a variable name, a cell array of variable names, or a logical vector. Alternatively, you can usevartype
to create a subscript that selects variables of a specified type.
Extended Capabilities
Version History
Introduced before R2006a