I have two arrays lets say A = [1;2;4;7;10;20];
B = [1;4;8];
Now I want to find the elements of A, that are not in B i.e; [2;7;10;20]. I just need their index that is the index of the elements [2;7;10;20] in A. How can I implement this in matlab. I can use loops and all. But that is not what I want. I want an elegant solution. Suggestions?
You can do that using the
ismemberfunction.will give you
If you really need the indices, you can use
find.Just as a reminder, you can always use logical indexing like so:
will give you