Finding the index of a cell element

2 次查看(过去 30 天)
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’?

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by