I have a matrix, for example:

А = [1 2 3 3 3 4 4 5 6] 

And I want to remove duplicate numbers along with the number itself, so that another matrix will turn out:

 Б = [1 2 5 6] 

    1 answer 1

    Actually code:

     A = [1 2 3 3 3 4 4 5 6] n = unique(A) for i = n id = ismember(A, i); if sum(id) > 1 A(id) = []; end end A 

    Result:

     A = 1 2 3 3 3 4 4 5 6 n = 1 2 3 4 5 6 A = 1 2 5 6