How can I find the elements of a cell array that are not common to another cell array?
36 views (last 30 days)
Show older comments
MathWorks Support Team
on 14 Apr 2014
Answered: MathWorks Support Team
on 14 Apr 2014
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
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) = [];
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!