Using ismember on vector with strings

2 visualizaciones (últimos 30 días)
Muazma Ali
Muazma Ali el 3 de Oct. de 2019
Comentada: Muazma Ali el 4 de Oct. de 2019
Hi,
I am wonderinh whether I can write something like this:
If any(ismember(result , [" nafor", "kform", "acet"]))

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by