Azzera filtri
Azzera filtri

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 visualizzazione (ultimi 30 giorni)
asking for a friend

Risposte (1)

Torsten
Torsten il 16 Set 2022
Modificato: Torsten il 16 Set 2022
str = ["asdfsd","bfgfd","cyf","ddfhf","effdg","dgdgdf"];
pat = "d";
[~,i] = find(contains(str,pat)==1)
i = 1×5
1 2 4 5 6

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by