How to get row indices of names ends with specified common substring
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have below cell array, and want to get row indices of names ends with "_A". I am working in Matlab2016a.
Names:
{'HATY_A';'VANU_BA';'IKLA_A';'PAIK_A';'HANYT_BH';'HAYIO_HNA';'HAKIO_A'}
desired_output:
rowIdx=
1
3
4
7
I use below code: pattern='_A'
rowIdx=endsWith(Names,pattern)
also tried
rowIdx=contains(Names,pattern)
but both doesn't work in 2016a. Kindly someone help how to get my desired output.
1 件のコメント
Stephen23
2018 年 9 月 3 日
編集済み: Stephen23
2018 年 9 月 3 日
For older versions:
>> Names = {'HATY_A';'VANU_BA';'IKLA_A';'PAIK_A';'HANYT_BH';'HAYIO_HNA';'HAKIO_A'};
>> find(~cellfun('isempty',regexp(Names,'_A$','once')))
ans =
1
3
4
7
Note that in many cases using logical indexing is more efficient than subscript indexing.
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Acquisition Toolbox Supported Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!