Using ismember on vector with strings

3 vues (au cours des 30 derniers jours)
Muazma Ali
Muazma Ali le 3 Oct 2019
Commenté : Muazma Ali le 4 Oct 2019
Hi,
I am wonderinh whether I can write something like this:
If any(ismember(result , [" nafor", "kform", "acet"]))

Réponse acceptée

meghannmarie
meghannmarie le 3 Oct 2019
Modifié(e) : meghannmarie le 3 Oct 2019
if you are trying to match string to string, try this:
if any(contains([' nafor','kform','acet'],result))
  5 commentaires
Stephen23
Stephen23 le 4 Oct 2019
Modifié(e) : Stephen23 le 4 Oct 2019
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 le 4 Oct 2019
No i was thinking of character vectors and I got my answer yesterday that I accepted :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by