Effacer les filtres
Effacer les filtres

unique values in cell array

32 vues (au cours des 30 derniers jours)
Franco
Franco le 27 Sep 2013
I have a cell array with both numerical values and strings
test1 = {1,2,3,'No';1,3,2,'Yes';2,2,2,'Yes'}
I need to find the unique values of each column, regardless of the data type. Anyone know how to do this? Thanks.

Réponses (1)

Wayne King
Wayne King le 27 Sep 2013
You could do this:
test1 = {1,2,3,'No';1,3,2,'Yes';2,2,2,'Yes'};
out = unique(cellfun(@num2str,test1,'uni',0));
and then convert the strings with numbers back to numbers.

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by