The dataset
data type might be removed in
a future release. To work with heterogeneous data, use the MATLAB^{®} table
data
type instead. See MATLAB table
documentation
for more information.
C = intersect(A,B)
C = intersect(A,B,vars)
C = intersect(A,B,vars,setOrder)
[C,iA,iB]
= intersect(___)
for C
= intersect(A,B
)dataset
arrays A
and B
returns
the common set of observations from the two arrays, with repetitions
removed. The observations in the dataset array C
are
in sorted order.
returns
the set of common observations from the two arrays, considering only
the variables specified in C
= intersect(A,B
,vars
)vars
, with repetitions
removed. The observations in the dataset array C
are
sorted by those variables.
The values for variables not specified in vars
for
each observation in C
are taken from the corresponding
observations in A
. If there are multiple observations
in A
that correspond to an observation in C
,
then those values are taken from the first occurrence.
returns
the observations in C
= intersect(A,B
,vars
,setOrder
)C
in the order specified
by setOrder
.
[
also returns index vectors C
,iA
,iB
]
= intersect(___)iA
and iB
such
that C = A(iA,:)
and C = B(iB,:)
.
If there are repeated observations in A
or B
,
then intersect
returns the index of the first occurrence.
You can use any of the previous input arguments.

Input dataset arrays.  

Cell array of strings containing variable names or a vector
of integers containing variable column numbers, indicating the variables
in Specify  

Flag indicating the sorting order for the observations in


Dataset array with the common set of observations in 

Index vector, indicating the observations in 

Index vector, indicating the observations in 