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