Effacer les filtres
Effacer les filtres

I have a 1x6 array X = {‘a’,’b’,’​c’,’d’,’e’​,’f’}. I want a command that returns the element of X that contains a particular string. E.g. a command that if I tell it to find ‘d

1 vue (au cours des 30 derniers jours)
John Cadigan
John Cadigan le 16 Sep 2022
Modifié(e) : Torsten le 16 Sep 2022
asking for a friend

Réponses (1)

Torsten
Torsten le 16 Sep 2022
Modifié(e) : Torsten le 16 Sep 2022
str = ["asdfsd","bfgfd","cyf","ddfhf","effdg","dgdgdf"];
pat = "d";
[~,i] = find(contains(str,pat)==1)
i = 1×5
1 2 4 5 6

Catégories

En savoir plus sur Characters and Strings 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