Trouble using strings in If statements using OR

16 Ansichten (letzte 30 Tage)
Sarah R
Sarah R am 20 Jan. 2022
Kommentiert: Stephen23 am 21 Jan. 2022
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!

Akzeptierte Antwort

Voss
Voss am 20 Jan. 2022
if race == "H2" || race == "H1" || race == "H3" || race == "H4"

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by