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!