I have two arrays, a and b, of different size. Each one contains unique values.
I want to compare both and if any value of array a is in array b, then I want to dele
Use setdiff
to find elements in one set but not the other.
setdiff(b, a)
Use intersect
with 3 output arguments to get the indices of the elements to be deleted:
[c, ia, ib] = intersect(a, b);
b (ib) = [];
Yet another option is to use the ISMEMBER function to remove elements from b
that are members of a
via logical indexing:
b(ismember(b,a)) = [];