Effacer les filtres
Effacer les filtres

duplicating strings in a cell array

1 vue (au cours des 30 derniers jours)
AT_HYZ
AT_HYZ le 2 Déc 2023
Commenté : madhan ravi le 2 Déc 2023
I have a cell array like this:
name = {'aa', 'bb', 'bb','cc','cc','ee','ff','ff','ff'};
I would like to get the indices which are duplicated. Idx = 2,4,7.
I use strcmp and it didn't work.

Réponse acceptée

madhan ravi
madhan ravi le 2 Déc 2023
Modifié(e) : madhan ravi le 2 Déc 2023
[~, b, c] = unique(name);
idx = b(sum(b(c) == unique(b(c)).') > 1)
  1 commentaire
madhan ravi
madhan ravi le 2 Déc 2023
[~, b, c] = unique(name);
idx = b(accumarray(c, 1) > 1)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by