I use the following code on several occasions to keep only the rows with the condition that X elements don't repeat:
[~, ind,~] = unique(strcat(a(:,2)a(:, 6)));a = a(ind,:);
In this case I keep the rows that have different combinations of the elements of column 2 and 6.
I use the functions unique and strcat because they work for cell type variables with both strings and numbers . The problem is that this code is not efficent and takes a lot of time to run. I was wondering if someone had a better solution. Thank you
Best Answer