MATLAB: Remove array values with multiple occurances from “parent” array

array valuesdata repetitions

How do you remove values in an array from a "master database" array? For example:
a = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]
b = [1, 1, 2, 4, 4, 4]
I would like to remove each occurance of each value in 'b' from 'a' to get:
c = 1, 2, 2, 3, 3, 3
setdiff(a, b) doesn't work because it removes all instances from 'a' including the repeating values (it even says no repetitions in the documentation):
c = 3
[~, col] = ismember(b, a)
a(col) = []
doesn't work because it only removes one instance of the numbers (the first index where it occured):
c = 1, 1, 2, 2, 3, 3, 3, 4, 4
Thanks for the help.

Best Answer

a = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4];
b = [1, 1, 2, 4, 4, 4];
c = a;
for i=b
c(find(c==i,1))=[];
end