String compare

11 ビュー (過去 30 日間)
Jörg
Jörg 2011 年 9 月 25 日
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

採用された回答

Daniel Shub
Daniel Shub 2011 年 9 月 25 日
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 件のコメント
Daniel Shub
Daniel Shub 2011 年 9 月 25 日
You tried it with a cell array?
Jörg
Jörg 2011 年 9 月 25 日
Ah, that did the trick. Thanks a lot!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by