String compare
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
likely a beginners question. I have a matrix containing strings, say
A=['aa';'bb']
now I'm looking for a function f(x,string) that will do row-wise string comparison such that
f(A,'aa') leads to [1;0]
is that possible? I failed to use strcmp.
Thanks Jörg
0 Kommentare
Akzeptierte Antwort
Daniel Shub
am 25 Sep. 2011
If you can use
A = {'aa'; 'bb'}
then
strcmp(A, 'aa')
works. The cell array for A might be better because it lets you have unequal length strings.
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!