Find unique column values in NxN cell array
Afficher commentaires plus anciens
I have a 1000x50 cell array with each column contining multiple duplicate entries.
simplified example:
names = {'red','blue','green';'red','orange','yellow';'orange','orange','red'};
{'red' } {'blue' } {'green' }
{'red' } {'orange'} {'yellow'}
{'orange'} {'orange'} {'red' }
I would to create a simplified array wich contains only the unique values from each of the indiviual columns:
result:
{'red' } {'blue' } {'green' }
{'orange'} {'orange'} {'yellow'}
{'red' }
Réponses (1)
Because the resulting variables could all have a different number of elements, I'm converting each variable into a scalar cell that contains the desired data
t = table({'red';'red';'orange'},{'blue';'orange';'orange'},{'green';'yellow';'red'})
t = varfun(@(x){unique(x,'stable')},t)
t.(1){:}
t.(2){:}
t.(3){:}
Catégories
En savoir plus sur Cell Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!