I have a process that is iteratively and randomly pruning a huge vector of integers and I want to find what elements are removed between each iteration. This vector has a lot of repetitions and using ismember() and setdiff() doesn't helped me much.
As an illustration if X = [1,10,8,5,10,3,5,2]:
step 0: X = 1,10,8,5,10,3,5,2
step 1: X = 1,10,8,10,3,5,2 (5 is removed)
step 2: X = 1,10,8,3,2 (10 and 5 are removed)
step 3: X = 10,8,3,2 (1 is removed)
step 4: X = 2 (10, 8 and 3 are removed)
step 5: X = [] (2 is finally removed)
I aim at finding the elements removed at each steps (ie. 5 then, 10 and 5 and so on). I could possibly find an overly complicated solution using hist(X, unique(X))
between steps, but I assume there exists a much more elegant (and cheaper!) solution in matlab.