How can I find the elements of a cell array that are not common to another cell array?

26 views (last 30 days)
I have 2 cell arrays containing strings. I would like to remove from one cell array the elements that also exist in the other array. How can I do that?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Apr 2014
Use the "intersect" function to find the intersection of both arrays. Then, remove from one array the elements that are common to the other array:
% Find the intersection
[C,ia,ib] = intersect(A,B, 'stable');
% Remove from A the intersection of A and B
AminusB = A;
AminusB(ia) = [];

More Answers (0)

Categories

Find more on Data Types in Help Center and File Exchange

Products


Release

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!