Set intersection of two arrays

returns
the data common to both `C`

= intersect(`A,B`

)`A`

and `B`

with
no repetitions.

If

`A`

and`B`

are numeric arrays, logical arrays, character arrays, categorical arrays, datetime arrays, duration arrays, or cell arrays of strings, then`intersect`

returns the values common to both`A`

and`B`

. The values of`C`

are in sorted order.If

`A`

and`B`

are tables, then`intersect`

returns the set of rows common to both tables. The rows of table`C`

are in sorted order.

`[`

returns `C`

,`ia`

,`ib`

]
= intersect(___,`setOrder`

)`C`

in
a specific order using any of the input arguments in the previous
syntaxes. `setOrder='sorted'`

returns the values
(or rows) of `C`

in sorted order. `setOrder='stable'`

returns
the values (or rows) of `C`

in the same order as `A`

,
and then `B`

. If no value is specified, the default
is `'sorted'`

.

Was this topic helpful?