MATLAB: Removing specific elements from array

arrayelementismember

Lets assume i have
a = [1 1 3 5];
c = [1 5];
i want to remove c from a and the output should be a = [1 3]
a = setdiff(a,c) %this works but it removes both the '1' .

Best Answer

>> a = [1,1,3,5];
>> c = [1,5];
>> [X,Y] = ismember(c,a);
>> a(Y(X)) = []
a =
1 3