Trouble using strings in If statements using OR

21 次查看(过去 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
Voss 2022-1-20
if race == "H2" || race == "H1" || race == "H3" || race == "H4"

更多回答(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