Finding the index of a cell element

2 visualizzazioni (ultimi 30 giorni)
Kamia Kavi
Kamia Kavi il 12 Dic 2022
Risposto: Voss il 12 Dic 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’?

Risposta accettata

Voss
Voss il 12 Dic 2022
A{1} = 'xname1x';
A{2} = 'xname2x';
A{3} = 'xname3x';
idx = find(contains(A,'name1'))
idx = 1

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by