Finding the index of a cell element

3 Ansichten (letzte 30 Tage)
Kamia Kavi
Kamia Kavi am 12 Dez. 2022
Beantwortet: Voss am 12 Dez. 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’?

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by