Find in Array of Strings

how do i find the row number for 'STG' in the following array of names as: 'asf' 'poif' 'STG' 'iam' 'no'

 採用された回答

Matt Fig
Matt Fig 2011 年 6 月 28 日

1 投票

Is your array a cell array or a character array? If it is a cell array,
A = {'asf'
'poif'
'STG'
'iam'
'no'}
strmatch('STG',A)
Or you can use:
find(strcmp(A,'STG'))

1 件のコメント

Jan
Jan 2011 年 6 月 28 日
I prefer the faster STRCMP method. +1

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2011 年 6 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by