필터 지우기
필터 지우기

Using ismember on vector with strings

조회 수: 3 (최근 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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by