Finding the index of a cell element

2 vues (au cours des 30 derniers jours)
Kamia Kavi
Kamia Kavi le 12 Déc 2022
Réponse apportée : Voss le 12 Déc 2022
I have a cell array as follows;
A{1} = 'xname1x';
A{2} = 'xname2x';
A{3} = 'xname3x';
How can I find the index of the element whose value contains ‘name1’?

Réponse acceptée

Voss
Voss le 12 Déc 2022
A{1} = 'xname1x';
A{2} = 'xname2x';
A{3} = 'xname3x';
idx = find(contains(A,'name1'))
idx = 1

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by