Using ismember on vector with strings

2 ビュー (過去 30 日間)
Muazma Ali
Muazma Ali 2019 年 10 月 3 日
コメント済み: Muazma Ali 2019 年 10 月 4 日
Hi,
I am wonderinh whether I can write something like this:
If any(ismember(result , [" nafor", "kform", "acet"]))

採用された回答

meghannmarie
meghannmarie 2019 年 10 月 3 日
編集済み: meghannmarie 2019 年 10 月 3 日
if you are trying to match string to string, try this:
if any(contains([' nafor','kform','acet'],result))
  5 件のコメント
Stephen23
Stephen23 2019 年 10 月 4 日
編集済み: Stephen23 2019 年 10 月 4 日
Note that [] is a concatenation operator, so this code:
[' nafor','kform','acet']
is just a complex way of writing this:
' naforkformacet'
Perhaps you actually intended to define strings, rather than character vectors?
Muazma Ali
Muazma Ali 2019 年 10 月 4 日
No i was thinking of character vectors and I got my answer yesterday that I accepted :)

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

その他の回答 (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