0
votes

It is a basic problem but I am not so much experienced in Matlab(Guide). What I have now is a cell array called Z with 21x2 elements: 21 rows 2 columns.

What I would like to do is to get only the first column (to show only 21x1). Then, in this column there is a list of names. Inside the 21 rows of this cell there are repeated names. I would like to run through each row of this 21x1 column, detect which are repeated. The repeated ones should be printed in the uitable in a white colour.

Any ideas?

1
How are you putting them into the table? Can you post the code which does that? - scenia
Also do you want to make all occurences white or just the ones after the first one? So should each name appear in black exactly once or should only unique names be in black and non-unique names in white? - scenia

1 Answers

0
votes

I believe this should deal with the core of your question:

A={'abc' 6;'de' 7;'abc' 8};

[C, ia] = unique(A(:,1));
idx = setdiff(1:size(A,1),ia);
A(idx,1)

This code will list all duplicates.