Find in Array of Strings

2 views (last 30 days)
Sam Da
Sam Da on 28 Jun 2011
how do i find the row number for 'STG' in the following array of names as: 'asf' 'poif' 'STG' 'iam' 'no'

Accepted Answer

Matt Fig
Matt Fig on 28 Jun 2011
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 Comment
Jan
Jan on 28 Jun 2011
I prefer the faster STRCMP method. +1

Sign in to comment.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!