how to find the position in a string array

8 visualizzazioni (ultimi 30 giorni)
attributes={'aaaa','bbbb','cccc','dddd' };
str='cccc';
how to find position 3 ?

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by