how to find the position in a string array

8 views (last 30 days)
attributes={'aaaa','bbbb','cccc','dddd' };
str='cccc';
how to find position 3 ?

Accepted Answer

Walter Roberson
Walter Roberson on 6 Apr 2014
Read the documentation in ismember()
  2 Comments
Shown
Shown on 6 Apr 2014
thanks, I got it.
[a,b]=ismember(str,attributes)
b
Jan
Jan on 6 Apr 2014
I'd prefer this instead:
index = find(strcmp(attributes, str))

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!