Trouble using strings in If statements using OR
조회 수: 15 (최근 30일)
이전 댓글 표시
I am trying to loop through and use IF statement as example:
if race == "H2" | "H1" | "H3" | "H4"
but I get error "Error using |
Input must be text or pattern."
If I try: race == "H2" || "H1" || "H3" || "H4"
I get error:
Conversion to logical from string is not possible.
"H1" and so forth are strings in Matlab
Thank you!
채택된 답변
Voss
2022년 1월 20일
if race == "H2" || race == "H1" || race == "H3" || race == "H4"
댓글 수: 1
Walter Roberson
2022년 1월 20일
Or alternately
if ismember(race, ["H1", "H2", "H3", "H4"])
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!