I have two cell arrays, X and Y. Each cell array is made up of strings : i.e, X{i} is a string for all i, and so is Y{i}. I would like to find the intersection of the two cell arrays, (presumably a third cell array} that has the strings common to both X and Y.
There is a single function that does this: intersect
For example:
>> X = {'a', 'b'; 'c', 'd'};
>> Y = {'c', 'd', 'e', 'f'};
>> Z = intersect(X, Y)
Z =
'c' 'd'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With